Debug School

rakesh kumar
rakesh kumar

Posted on

Flutter configuration Errors checklist

Errors:your app not runs on emulator due to continously running
Error2:ERROR: R8: Missing class
Error3:# Please add these rules to your existing keep rules in order to suppress warnings. This is generated automatically by the Android Gradle plugin.
-dontwarn javax.lang.model.element.Modifier

Errors:your app not runs on emulator due to continously running

Flutter: Running Gradle task 'assembleDebug'...
Flutter:installing/app/gradle/assembleDebug
Enter fullscreen mode Exit fullscreen mode

Checklist

package com.cotocus.motoshare.partner
Enter fullscreen mode Exit fullscreen mode

use ctrl find or search
check all 3 places wheather u change package name
1.C:\Project\motoshare_partner\android\app\build.gradle
2.C:\Project\motoshare_partner\android\app\src\main\AndroidManifest.xml
3.C:\Project\motoshare_partner\android\app\src\main\kotlin\com\example\motoshare_partner\MainActivity.kt

Image description

Checklist2
sdk version and emulator should exactly match
sdk version in C:\Project\motoshare_partner\android\app\build.gradle

  targetSdk = 34 // Replace with your desired targetSdkVersion
Enter fullscreen mode Exit fullscreen mode
 defaultConfig {
        applicationId = "com.cotocus.motoshare.partner"
        minSdk = 21 // Replace with your minimum SDK version
        targetSdk = 34 // Replace with your desired targetSdkVersion
        versionCode = 1
        versionName = "1.0.0"

        multiDexEnabled = true // Enable multidex support if needed
    }
Enter fullscreen mode Exit fullscreen mode

Image description

Error2:ERROR: R8: Missing class

com.google.errorprone.annotations.CanIgnoreReturnValue (referenced from: com.google.crypto.tink.KeysetManager com.google.crypto.tink.KeysetManager.add(com.google.crypto.tink.KeyTemplate) and 52 other contexts) correspong dependencies or rule in proguard for avoid
Enter fullscreen mode Exit fullscreen mode

create one file by right click android/app

proguard-rules.pro==>C:\Project\motoshare_partner\android\app\proguard-rules.pro
Enter fullscreen mode Exit fullscreen mode

Solution:
2 way
check:C:\Project\motoshare_partner\build\app\outputs\mapping\release\mapping.txt check after build apk what are the things i need to
dontwarn in proguard or add dependency
1st way== add rule by keep class and keepattribute in proguard and allow dependency in build gradle
2nd way:simply suppress warnings for error-prone annotations by dontwarning ==-dontwarn com.google.errorprone.annotations.**

I am following 1st way

Add Missing Dependency and Update ProGuard Rules

  1. Add the Missing Dependency In your app/build.gradle, include the error-prone annotations library:
dependencies {
    // Add error-prone annotations library
    implementation 'com.google.errorprone:error_prone_annotations:2.15.0'

    // Add Tink library (if not already present)
    implementation 'com.google.crypto.tink:tink-android:1.9.0'

    // Other necessary dependencies
    implementation 'androidx.multidex:multidex:2.0.1'
}
Enter fullscreen mode Exit fullscreen mode

Image description

  1. Update ProGuard Rules Modify your proguard-rules.pro file to prevent ProGuard or R8 from stripping the error-prone annotations:

proguard

# Keep error-prone annotations
-keep class com.google.errorprone.annotations.** { *; }
-keepattributes *Annotation*
Enter fullscreen mode Exit fullscreen mode

If you want to suppress warnings for error-prone annotations, you can add the following (optional):

-dontwarn com.google.errorprone.annotations.**
Enter fullscreen mode Exit fullscreen mode
  1. Clean and Rebuild After making the changes, run the following commands to ensure everything is applied correctly:
flutter clean
flutter pub get
flutter build apk --release
Enter fullscreen mode Exit fullscreen mode

Error3:# Please add these rules to your existing keep rules in order to suppress warnings.

This is generated automatically by the Android Gradle plugin.
-dontwarn javax.lang.model.element.Modifier

Solution:
2 way
check:C:\Project\motoshare_partner\build\app\outputs\mapping\release\mapping.txt check after build apk what are the things i need to
dontwarn in proguard or add dependency
1st way== add rule by keep class and keepattribute in proguard and allow dependency in build gradle
2nd way:simply suppress warnings for error-prone annotations by dontwarning ==-dontwarn com.google.errorprone.annotations.**

i am folling 2nd way
Add the -dontwarn Rule to ProGuard
Update your proguard-rules.pro file to suppress the warning:

# Suppress warnings for javax.lang.model.element.Modifier
-dontwarn javax.lang.model.element.Modifier
Enter fullscreen mode Exit fullscreen mode

Image description

Top comments (0)