Flutter Release apk is not working properly?

后端 未结 8 1029
深忆病人
深忆病人 2021-02-07 07:41

I had run this flutter build apk to release my App. Now I had build verison 2 of that.

Now again I want to release my version 2 App.To get the release apk

相关标签:
8条回答
  • 2021-02-07 07:54

    I decide to open the MyProject/android folder in android studio and build the apk from android studio. It finally worked properly.

    0 讨论(0)
  • 2021-02-07 07:55

    I got the release APK which is not working good named as app-release.apk but just in the folder previous to that one there is another apk app.apk which do not have that debug strip at top and working fine as in debug mode and size is almost same.

    0 讨论(0)
  • 2021-02-07 07:59

    I think you need

    flutter clean
    

    (I'd consider it a bug that this is necessary, but I'm encountering it as well)

    and

    flutter build apk --release
    
    0 讨论(0)
  • 2021-02-07 08:01

    I hope this can help someone. I ran into a problem that my release version does not works and there are no any error messages in logcat. The problem turned out to be that I had FutureBuilder in which i start Future<void>. By running flutter run it works properly (snapshot.hasData was true), but in release version it was always false. Of course, documentation of the FutureBuilder says that hasData should be false in this case. But in fact in debug mode it has different behaviour.

    P.S. Another possible problems: Now my app still not working, but this time i saw on logcat next error:

    Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)

    Downgrading gradle plugin version from 7.* to 3.5.4 solves this issue.

    classpath 'com.android.tools.build:gradle:3.5.4'

    0 讨论(0)
  • 2021-02-07 08:07
    1. you can change in local.properties android project

          sdk.dir=D:/SDK               //your android SDK location
          flutter.sdk=D:\\Flutter\\flutter  //your flutter SDK location
          flutter.versionName=1.0.0
          flutter.versionCode=2
          flutter.buildMode=release
      
    2. changes in your android/app/build.gradle file

           buildTypes {
                  release {
                      // if everything ok then not add 
                      //minifyEnabled true 
                      //another you can remove minifyEnabled true
                      proguardFiles getDefaultProguardFile('proguard- 
                       android.txt'), 'proguard-rules.pro'
                      signingConfig signingConfigs.release
                  }
              }
      
    3. you can also changes in android/app/build.gradle defaultConfig method body.

        multiDexEnabled true
      
    4. if you want to migrate to androidx then do it setup.

      dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.1.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' implementation 'androidx.multidex:multidex:2.0.1'

      }

      1. and clean before create build folder by following this cmd.

         - flutter clean
        
         - flutter build apk --release
        
         - flutter install
        

    6.Release Apk location.

            in `android studio termial` or inside `project-root` you can navigate to this.
    
            cd build\app\outputs\apk\release
    
    0 讨论(0)
  • 2021-02-07 08:10

    If your problem is that the flutter build (APK, bundle) isn't making API calls in a real device, this is because you need to add the Internet permission to Android Manifest before creating the release/build.

    By default, "internet use" will work fine on the emulator but not on a real device.

    To fix this, simply:

    Open the file "android/app/src/main/AndroidManifest.xml" and add the proper user-permission:

    <manifest> 
    ...
     <uses-permission android:name="android.permission.INTERNET"/>
    ...
    </manifest>
    

    And then create your build again.

    0 讨论(0)
提交回复
热议问题