Closed r4v3r23 closed 3 years ago
Hi @r4v3r23
Please remove proguard from your build.gradle
Follow this Configure signing in gradle
can you please provide your flutter doctor -v
and flutter build apk --verbose
?
Thank you
Hi @r4v3r23 Please remove proguard from your
build.gradle
Follow this Configure signing in gradlecan you please provide your
flutter doctor -v
andflutter build apk --verbose
?Thank you
there is no proguard in build.grade
flutter doctor -v
:
flutter doctor -v [✓] Flutter (Channel master, v1.16.4-pre.22, on Linux, locale en_US.UTF-8) • Flutter version 1.16.4-pre.22 at /home/x0x/Android/flutter • Framework revision e4a61dfdea (3 days ago), 2020-03-29 21:01:02 -0400 • Engine revision 361d5d5320 • Dart version 2.8.0 (build 2.8.0-dev.18.0 1402e8e1a4)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at /home/x0x/Android/Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.3 • Java binary at: /opt/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211) • All Android licenses accepted.
[✓] Android Studio (version 3.6) • Android Studio at /opt/android-studio • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
[!] Connected device ! No devices available
Hi @r4v3r23 Do you add proguard? You don't need it R8 is the the new code shrinker for Android and it's already enabled by default in flutter project
Only follow this guide for preparing release apk
Thank you
buildscript { ext.kotlin_version = '1.3.70' repositories { google() jcenter() }
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects { repositories { google() jcenter() maven { url "https://raw.githubusercontent.com/guardianproject/gpmaven/master" } maven { url 'https://jitpack.io' } } }
rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }
task clean(type: Delete) { delete rootProject.buildDir }
Hi @r4v3r23 that is project build.gradle Please share app build.gralde Thank you
Hi @r4v3r23 that is project build.gradle Please share app build.gralde Thank you
app build.gradle:
-----------------------------------------
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 29
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.invertedx.sentinelx"
multiDexEnabled true
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
resValue "string", "app_name", "Sentinelx"
}
debug {
applicationIdSuffix ".debug"
resValue "string", "app_name", "Sentinelx Staging"
debuggable true
}
profile {
applicationIdSuffix ".debug"
resValue "string", "app_name", "Sentinelx Staging"
debuggable true
}
}
splits {
// Configures multiple APKs based on ABI.
abi {
enable true
reset()
// include "armeabi-v7a", "arm64-v8a"
universalApk true
}
}
}
ext.abiCodes = ['armeabi-v7a': 2, 'arm64-v8a': 3]
import com.android.build.OutputFile
// For each APK output variant, override versionCode with a combination of
// ext.abiCodes * 1000 + variant.versionCode. In this example, variant.versionCode
// is equal to defaultConfig.versionCode. If you configure product flavors that
// define their own versionCode, variant.versionCode uses that value instead.
android.applicationVariants.all { variant ->
// Assigns a different version code for each output APK
// other than the universal APK.
variant.outputs.each { output ->
// Stores the value of ext.abiCodes that is associated with the ABI for this variant.
def baseAbiVersionCode =
// Determines the ABI for this variant and returns the mapped value.
project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
// Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
// the following code does not override the version code for universal APKs.
// However, because we want universal APKs to have the lowest version code,
// this outcome is desirable.
if (baseAbiVersionCode != null) {
// Assigns the new version code to versionCodeOverride, which changes the version code
// for only the output APK, not for the variant itself. Skipping this step simply
// causes Gradle to use the value of variant.versionCode for the APK.
output.versionCodeOverride =
baseAbiVersionCode * 1000 + variant.versionCode
}
}
}
flutter {
source '../..'
}
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.bouncycastle:bcprov-jdk15on:1.56'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'org.apache.commons:commons-lang3:3.4'
implementation 'com.lambdaworks:scrypt:1.4.0'
implementation 'commons-codec:commons-codec:1.10'
implementation 'com.google.guava:guava:28.2-jre'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.protobuf:protobuf-java:3.8.0'
implementation 'com.squareup.okhttp3:okhttp:4.4.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation('com.google.zxing:core:3.4.0') {
}
implementation(project(':torservice')) {
exclude module: 'org.slf4j'
exclude group:'org.slf4j'
}
implementation 'org.torproject:tor-android-binary:0.4.2.5'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
@TahaTesser flutter run --release
works & builds release apk but flutter build apk --release
gives the errors
I meet the same problem.
[ ] FAILURE: Build failed with an exception.
[ ] * What went wrong:
[ ] Execution failed for task ':app:minifyReleaseWithProguard'.
[ ] > java.io.IOException: java.lang.NullPointerException
[ ] * Try:
[ ] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[ ] * Get more help at https://help.gradle.org
[ ] BUILD FAILED in 2m 19s
flutter run --release
and flutter build apk --release
and flutter build apk -v --no-shrink --no-tree-shake-icons --release
all execute fail.
But flutter run --debug
can execute successful.
flutter doctor -v
[✓] Flutter (Channel stable, 2.0.0, on macOS 11.2.2 20D80 darwin-x64, locale zh-Hans-CN)
• Flutter version 2.0.0 at /Users/weslywang/project/android/flutter
• Framework revision 60bd88df91 (4 个月前), 2021-03-03 09:13:17 -0800
• Engine revision 40441def69
• Dart version 2.12.0
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc5)
• Android SDK at /Users/weslywang/Library/Android/sdk
• Platform android-30, build-tools 31.0.0-rc5
• ANDROID_HOME = /Users/weslywang/Library/Android/sdk/platform-tools
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.10.0
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.3)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
[✓] VS Code (version 1.41.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.8.1
My build.gradle as follows
buildTypes {
release {
multiDexKeepProguard file('multidex-config.pro')
minifyEnabled true
useProguard true
shrinkResources true
signingConfig signingConfigs.release
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
multiDexKeepProguard file('multidex-config.pro')
minifyEnabled false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
@TahaTesser
i have same error
Me too...
Closing this as a duplicate of https://github.com/flutter/flutter/issues/53409. Please follow-up in linked issue for further updates.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v
and a minimal reproduction of the issue.
flutter build apk --release
spits out a long log with this in red at the end:flutter build apk --debug
andflutter run
work just fine