Delete unaligned apks using Gradle script in Android Studio 3.0? - android

After upgrading to Android Studio 3.0/build tools 3.0.0, a piece of my Gradle build script (which is used to delete unaligned apks after assembling) failed during build.
FYI I was using the Gradle scripts from this post.
Now it's always saying output.packageApplication.outputFile is an unknown property (Could not get unknown property 'outputFile' for task...).
I am wondering if there's an alternative way to get the unaligned file?
Any comment is appreciated, thanks in advance.

As of Gradle 2.2, there isn't an unaligned APK, so deleting it is unnecessary. (I just ran into this also - and noticed that they were missing.)
See the note here:
https://issuetracker.google.com/issues/37121010
So your code to remove them is unnecessary.
Also, to address the failure - as of Gradle 3.0 there are some features that are not working (like the variant outputFile). See the reference here on how to avoid that error:
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#variant_api

Related

Gradle build failing - "A problem was found with the configuration of task ':app:generateSafeArgsDebug' (type 'ArgumentsGenerationTask')."

I'm trying to open and run the android architecture components sample project here: https://github.com/android/architecture-components-samples/tree/main/GithubBrowserSample in Android Studio. One one machine I'm able to get the project built and run just fine, but on my primary machine I'm seeing a build task error:
A problem was found with the configuration of task ':app:generateSafeArgsDebug' (type 'ArgumentsGenerationTask').
> No value has been specified for property 'enableGradleWorkers'.
I've tried the version of gradle and the gradle plugin that the project seems to have been built with, as well as the latest of each. I do have "android.enableGradleWorkers=true" specified in gradle.properties.
I haven't found this message when searching around, but I often see similar-looking errors when opening projects from different sources. I'd love to be able to fix this one, and ideally understand more about what to check when encountering build errors with projects from different sources in the future.

Android Room + Kotlin + Kapt + IntelliJ + MacOS Catalina: java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8

Using Android Room with Kapt on MacOS Catalina, I get the following errors building the project. The project builds successfully if I remove kapt "androidx.room:room-compiler:$room_version" from my build.gradle.
Failed to load native library:sqlite-3.25.2-60e239c7-424b-4b75-bfd5-b2df4aa8e01a-libsqlitejdbc.jnilib. osinfo: Mac/x86_64
java.lang.UnsatisfiedLinkError: $TMPDIR/sqlite-3.25.2-60e239c7-424b-4b75-bfd5-b2df4aa8e01a-libsqlitejdbc.jnilib: dlopen($TMPDIR/sqlite-3.25.2-60e239c7-424b-4b75-bfd5-b2df4aa8e01a-libsqlitejdbc.jnilib, 1): no suitable image found. Did find:
$TMPDIR/sqlite-3.25.2-60e239c7-424b-4b75-bfd5-b2df4aa8e01a-libsqlitejdbc.jnilib: code signature in ($TMPDIR/sqlite-3.25.2-60e239c7-424b-4b75-bfd5-b2df4aa8e01a-libsqlitejdbc.jnilib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
Failed to load native library:sqlite-3.25.2-79b61bc4-bdd0-4451-a523-5baa49728398-libsqlitejdbc.jnilib. osinfo: Mac/x86_64
java.lang.UnsatisfiedLinkError: $TMPDIR/sqlite-3.25.2-79b61bc4-bdd0-4451-a523-5baa49728398-libsqlitejdbc.jnilib: dlopen($TMPDIR/sqlite-3.25.2-79b61bc4-bdd0-4451-a523-5baa49728398-libsqlitejdbc.jnilib, 1): no suitable image found. Did find:
$TMPDIR/sqlite-3.25.2-79b61bc4-bdd0-4451-a523-5baa49728398-libsqlitejdbc.jnilib: code signature in ($TMPDIR/sqlite-3.25.2-79b61bc4-bdd0-4451-a523-5baa49728398-libsqlitejdbc.jnilib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
Which produces the following exception
Caused by: java.lang.UnsatisfiedLinkError: org.sqlite.core.NativeDB._open_utf8([BI)V
at org.sqlite.core.NativeDB._open_utf8(Native Method)
at org.sqlite.core.NativeDB._open(NativeDB.java:78)
at org.sqlite.core.DB.open(DB.java:195)
at org.sqlite.SQLiteConnection.open(SQLiteConnection.java:243)
at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:61)
at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:28)
at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:21)
at org.sqlite.JDBC.createConnection(JDBC.java:116)
at androidx.room.verifier.DatabaseVerifier$Companion.create(DatabaseVerifier.kt:104)
at androidx.room.processor.DatabaseProcessor.doProcess(DatabaseProcessor.kt:82)
at androidx.room.processor.DatabaseProcessor.process(DatabaseProcessor.kt:57)
at androidx.room.RoomProcessor$DatabaseProcessingStep.process(RoomProcessor.kt:134)
at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:330)
at com.google.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:181)
at org.jetbrains.kotlin.kapt3.base.incremental.IncrementalProcessor.process(incrementalProcessors.kt)
at org.jetbrains.kotlin.kapt3.base.ProcessorWrapper.process(annotationProcessing.kt:147)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:985)
... 39 more
It looks like this is different from https://github.com/xerial/sqlite-jdbc/issues/97, which is the only issue I could find any information about. Is there any way to work around this issue?
Edit:
I ended up finding this blog post, which led me to this JDK issue. I verified that ./gradlew :app:kaptDebugKotlin worked with my JDK11, and updated IDEA to use that JDK as it's runtime, as well as telling it to execute builds with gradle instead of IDEA. Neither of those seemed to fix the issue - running ./gradlew clean :app:kaptDebugKotlin in my terminal with JDK11 succeeded, but running that gradle task through IDEA failed.
I ended up working around it by removing gradle-aware make from my run configuration, and running ./gradlew :app:assembleDebug every time I make changes to the app. It's a little annoying and adds an extra step, but I can still run/update the app.
Figured it out - it turns out the Gradle setting for Java SDK is ignored in Android projects, and instead the Java SDK from the Android SDK is used for gradle tasks. Setting the Android SDK's Java SDK to JDK11 fixed the issue, because that JDK has the fix for JDK-8223671

Unity 2018.3 android dex merging issue

Before you decide to dismiss this post as "duplicate" without even reading it, understand that I have looked at a TON of posts related to this topic and I can't find a solution for my instance, including all of the ones that StackOverflow suggested. Most of the posts are for Android Studio instead of unity.
My error is given in Unity when trying to build to android, it crashes here.
CommandInvokationFailure: Gradle build failed.
C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleDebug"
stderr[
D8: Program type already present: com.unity3d.ads.BuildConfig
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformDexArchiveWithExternalLibsDexMergerForDebug'.
I've tried changing stuff with a build.gradle file like a lot of posts suggest, but I can't get anything to work.
The error didn't exist in Unity 2018.2. I checked right before I updated, but the update is now throwing this issue.
Does anyone have any UNITY specific ideas what to do here? I've tried so many things and nobody's post has been able to help me yet.
Thanks for any help
You can open the PackageManage under Window in the menu bar and remove Advertisement or you can delete the com.unity.ads file of Library/PackageCache in the project directory to resolve this issue.
This error probably happens when you add a library which is not compatible with your compileSdkVersion.
In your case you can have libs that were not imported by default by unity (and now are)
or there can be a problem with the Build Tools version. (You can try updating them)
I had similar problem a few versions ago, but I don't remember how I fixed it.
I didn't have time to upgrade to unity 2018.3 yet. (So the tips are more like guesses, but it may help you solve the issue.)
My settings (Mac):
- Android Studio 2.3
- Unity 2019.1.5f1:
- Player Settings -> Other Settings –> Scripting Runtime Version = .Net 4
- Package Manager -> Advertisement: Uninstalled
- Preferences -> External Tools -> Android: checked Installed with Unity (everything)
My solution:
- delete GoogleMobileAds from project
- delete PlayServicesResolver from project
- delete Plugins from project
- Import Package -> Custom Package -> GoogleMobileAds.unitypackage (3.15.1 in my case)
Dex Errors generally occur when you have too many methods imported in a project, not because of a specific package. I assume upgrading to new version made you import new stuff to your project.
You need to enable ProGuard.
Cause: http://twinkfed.homedns.org/Android///tools/building/multidex.html
Fix: https://www.youtube.com/watch?v=va0FQNlBUX0

Android Studio Execution failed for task ':app:mergeDebugResources' with special chars in username

i have a strange error with AAPT2 iin Android Studio. I think it has something to do with german special characters in my account name in windows.
If i set my gradle to version 3.0.1 and also set android.enableAapt2 to false everything works fine. But since i researched, setting the option is not a solution to the problem.
Now if i set the gradle version to 3.1.2 and remove android.enableAapt2 from the properties i get the following error message:
And this one:
One way to solve the problem was to create a new account in windows without special chars in the name. It compiled and did run very well. I really tried everything in the web but could not find a solution to the problem.
Maybe you can help me.
First of all check your build log botom of the build section you shared whether any error related to your project showing or not. If error showing then fix those. Build and run again and fix all the error comes up. It will eliminate aapt2 issue without changing android gradle plugin.
Secondly if there is not any project related error showing in the build log but still its showing aapt2 error then you can fix it by following below steps.
Update your android gradle plugin in your project level build.gradle file like below:
classpath 'com.android.tools.build:gradle:3.2.0-alpha13'
Now update android.enableAapt2=true. Then check and build your project.

Gradle execution fails: Unknown command-line option '--daemon'

I use latest Android Studio (0.8.2). On my other PC the same code is successfully builded.
It means that build scripts are correct.
So I assume that it is something with Gradle configuration, but I double rechecked all configs:
I completely removed .gradle folder under C:\Windows\Users{MyUser}.gradle to delete old configurations;
gradle.properties file doesn`t have any uncommented options
What do I miss?
NOTE! I have not specified '--daemon' option. Or I only think so:( I can`t find it in Gradle default and project specific settings
Also I created absolutely new project in the studio. It didn`t help - the same error(
The answer is very simple. It seems that new version of Android studio imported all setting from previous one. Some of old options added additional options to compiler
Android Studio always uses a Gradle daemon. It connects to the daemon via the Gradle Tooling API, and perhaps the latter doesn't understand --daemon (because it's redundant).

Categories

Resources