Issues when Updating Old Projects to TargetSDK 35
- Preview stage (2024)
- To resolve this issue, you need to upgrade gradle to 8.0+, but various problems arise…
- Solution 1:
Add the following to gradle.properties
kotlin.jvm.target.validation.mode = IGNORE
- Solution 2:
Referring to the Kid project, add the following to gradle.properties
COMPILE_JAVA_VERSION=17
And specify the Java version in the corresponding build.gradle
- Solution:
Add the following to gradle.properties
android.defaults.buildfeatures.buildconfig=true
- Solution:
Add the following to gradle.properties
android.defaults.buildfeatures.aidl=true
- Solution:
- Downgrade com.google.firebase:firebase-ads to 22.3.0 in
AirDroid/build.gradle
- Downgrade com.google.android.gms:play-services-ads to 22.3.0 in
AdmobModule/build.gradle
- Downgrade com.google.firebase:firebase-ads to 22.3.0 in
- References: https://issuetracker.google.com/issues/327696048 https://stackoverflow.com/questions/78085458/manifest-merger-failed-with-agp-8-3-0 https://stackoverflow.com/questions/78350965/manifest-merger-failed-attribute-propertyandroid-adservices-ad-services-confi
- Add the following to gradle.properties
android.nonFinalResIds=false
-
Error changed to:
- The files that AA (AndroidAnnotation) should create are not being created properly. Following AA’s debugging method, check androidannotations.log in the build folder:
10:13:18.48 [WorkerExecutor Queue Thread 2] ERROR o.a.i.h.AndroidManifestFinder:152 - Could not find the AndroidManifest.xml file, using generation folder [/Users/sion/gerrit/airmirror/airdroid/AirDroid/build/generated/source/kapt/channelDebug])
- Found that the AndroidManifest.xml file could not be found.
- Referencing other projects, add the following to AirDroid/Build.gradle:
javaCompileOptions { annotationProcessorOptions { arguments["androidManifestFile"] = "$projectDir/src/main/AndroidManifest.xml" } }
- The files that AA should create are still not being created properly.
- Check androidannotations.log again:
10:25:09.812 [WorkerExecutor Queue] ERROR o.a.i.r.ProjectRClassFinder:49 - The generated .R class cannot be found
The problem has changed to not finding the .R file.
- Change javaCompileOptions in AirDroid/Build.gradle as follows:
javaCompileOptions { annotationProcessorOptions { arguments = [ 'androidManifestFile': "$projectDir/src/main/AndroidManifest.xml", 'resourcePackageName': getPackageName("sandstudio") ] } }
Compilation succeeded! However, the app crashes when opened
-
Firebase performs auto-initialization through a ContentProvider called FirebaseInitProvider, so there’s no need to separately add FirebaseApp.initializeApp(Context).
- Check related logs:
2025-02-13 15:12:46.078 4449-4449 FirebaseApp com.sand.airmirror W Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project. 2025-02-13 15:12:46.078 4449-4449 FirebaseInitProvider com.sand.airmirror I FirebaseApp initialization unsuccessful
Found that initialization failed.
- Solution: Upgrade google-services to 4.4.2 in the root directory’s build.gradle ```java buildscript { dependencies { classpath ‘com.google.gms:google-services:4.4.2’ } }
<div class="c-border-main-title-2">Release build error while uploadCrashlyticsMappingFileIntlRelease</div>
```java
* What went wrong:
A problem was found with the configuration of task ':AirDroid:uploadCrashlyticsMappingFileIntlRelease' (type 'UploadMappingFileTask').
- In plugin 'com.google.firebase.crashlytics' type 'com.google.firebase.crashlytics.buildtools.gradle.tasks.UploadMappingFileTask' property 'googleServicesFile' specifies file '/media/build/workspace/airmirror-release/AirDroid/build/generated/res/google-services/intl/release/values/values.xml' which doesn't exist.
Reason: An input file was expected to be present but it doesn't exist.
- Solution:
Upgrade firebase-crashlytics to 3.0.3 in the root directory’s build.gradle
buildscript { dependencies { classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.3' } }
- channelRelease build failure information:
```java
Task :AdmobModule:minifyChinaReleaseWithR8 FAILED ERROR: Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /media/build/workspace/airmirror-release/AdmobModule/build/outputs/mapping/chinaRelease/missing_rules.txt. ERROR: R8: Missing class java.lang.invoke.StringConcatFactory (referenced from: java.lang.String com.sand.admobmodule.SandAdRewardManager$AdSource.toString() and 41 other contexts)
* Check:
`/AdmobModule/build/outputs/mapping/chinaRelease/missing_rules.txt`
```java
# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn java.lang.invoke.StringConcatFactory
- Solution:
Add the following to AdmobModule’s proguard-rules.pro:
-dontwarn java.lang.invoke.StringConcatFactory
GreenDao
has stopped updating, and the releases on GitHub are at most 3.3.0, but checking mvnrepository and GitHub commit messages shows thatgreendaoPlugin
was quietly updated in 2023. Actually upgradinggreen dao plugin
to3.3.1
makessync project
work.- https://mvnrepository.com/artifact/org.greenrobot/greendao-gradle-plugin
- https://github.com/greenrobot/greenDAO/commit/1c45c2c581a5cd1dc2da025b3628d60dcf65bbed
- Later, another error occurs
- In this case, change the targetGenDir in gradle’s greendao settings to
targetGenDir = file("$buildDir/generated/source/greendao")
- Also add corresponding arguments to kapt
kapt { correctErrorTypes = true arguments { arg("greendao.targetGenDir", file("$buildDir/generated/source/greendao").absolutePath) arg("greendao.schema", "$projectDir/src/main/java") arg("greendao.daoPackage", "com.sand.airsos.database") arg("greendao.targetGenDir", "$projectDir/src/main/java") } }
- In this case, change the targetGenDir in gradle’s greendao settings to