Trying to use a JAR created with Clojure in Android - java

I want to use Clojure to create a library that I'll use in an Android project.
Experimenting with this, I've made an Uberjar from a test library in Leiningen.
Then I import it into my Android project.
But I'm getting this error :
AGPBI: {"kind":"error","text":"MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeExtDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform file 'mylib.jar' to match attributes {artifactType=android-dex, dexing-enable-desugaring=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.usage=java-runtime-jars}
> Execution failed for DexingNoClasspathTransform: /media/phil/54AE4F563BCE86E8/DATA/new_dev_tree/small_experiments/clj-jar-for-android/TestAJar/app/libs/mylib.jar.
> Error while dexing.
> Failed to transform file 'mylib.jar' to match attributes {artifactType=android-dex, dexing-enable-desugaring=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.usage=java-runtime-jars}
> Execution failed for DexingNoClasspathTransform: /media/phil/54AE4F563BCE86E8/DATA/new_dev_tree/small_experiments/clj-jar-for-android/TestAJar/app/libs/mylib.jar.
> Error while dexing.
What exactly is going wrong here? Is it about the Android version? Or the file path? Or something completely different?

Related

Android resource linking failed

I need to generate app bundle, but the error say :
Execution failed for task ':app:processReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
> Android resource linking failed
C:\Users\fajri\AndroidStudioProjects\Assessment\app\build\intermediates\packaged_manifests\release\AndroidManifest.xml:36: error: resource mipmap/ic_launcher (aka com.si20b.assessment:mipmap/ic_launcher) not found.
C:\Users\fajri\AndroidStudioProjects\Assessment\app\build\intermediates\packaged_manifests\release\AndroidManifest.xml:36: error: resource mipmap/ic_launcher_round (aka com.si20b.assessment:mipmap/ic_launcher_round) not found.
error: failed processing manifest.
i already put my icon in my android project
when you create your image assets make sure you choose main mode.

Can not extract resource from com.android.aaptcompiler.ParsedResource#1c9d41e0

This is the other problem:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
> Resource compilation failed (Failed to compile values resource file /Users/bungaallysah/AndroidStudioProjects/splashscreen/app/build/intermediates/incremental/debug/mergeDebugResources/merged.dir/values/values.xml. Cause: java.lang.IllegalStateException: Can not extract resource from com.android.aaptcompiler.ParsedResource#1c9d41e0.,Can not extract resource from com.android.aaptcompiler.ParsedResource#23f7a22d.). Check logs for more details.
I've tried to setup the gradle, but there's no problem with that.

Flutter Execution failed for task ':app:mergeReleaseResources'

Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-hdpi\ic_launcher.png: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png: error: file failed to compile.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource compilation failed
AAPT: D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: error: failed to read PNG signature: file does not start with PNG signature.
D:\Flutter Projects\Areading-master\android\app\src\main\res\mipmap-mdpi\ic_launcher.png: error: file failed to compile.
This Error Happened when I try to build the project by this command flutter build apk --split-per-abi I don't know what is that about? please Help.
The builder optimizes the images in your app, in this case the png images. This is to reduce the size of the apk. It is unable to do so in your case. To run without optimization you can put the following in your build.gradle
android {
buildTypes {
release {
crunchPngs false // or true
}
}
}
I changed the .png file to .jpg in res/drawable and it worked for me

How do I fix my React Native failing Android build in Gradle? com.google.firebase:firebase-iid is being requested by various other libraries

I have tried generating a signed APK according to the instructions here: https://facebook.github.io/react-native/docs/signed-apk-android
When running ./gradlew assembleRelease, I get a build error as seen below. My app uses Google Firebase for authentication and tipsi-stripe as one of its main libraries. It is a detached Expo build.
I have tried adding additional dependencies, including Firebase core in app/build.gradle
The error in the terminal.
❯ ./gradlew assembleRelease
Parallel execution is an incubating feature.
{..}
> Task :tipsi-stripe:compileReleaseRenderscript FAILED
> Task :app:checkDevKernelReleaseClasspath FAILED
> Task :react-native-firebase:compileReleaseRenderscript FAILED
FAILURE: Build completed with 3 failures.
1: Task failed with an exception.
-----------
* What went wrong:
Failed to capture fingerprint of input files for task ':tipsi-stripe:compileReleaseRenderscript' property 'importDirs' during up-to-date check.
> The library com.google.firebase:firebase-iid is being requested by various other libraries at [[16.2.0,16.2.0]], but resolves to 17.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
==============================================================================
2: Task failed with an exception.
-----------
* What went wrong:
Failed to capture fingerprint of input files for task ':app:checkDevKernelReleaseClasspath' property 'compileClasspath' during up-to-date check.
> The library com.google.firebase:firebase-iid is being requested by various other libraries at [[16.2.0,16.2.0]], but resolves to 17.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
==============================================================================
3: Task failed with an exception.
-----------
* What went wrong:
Failed to capture fingerprint of input files for task ':react-native-firebase:compileReleaseRenderscript' property 'importDirs' during up-to-date check.
> The library com.google.firebase:firebase-iid is being requested by various other libraries at [[16.2.0,16.2.0]], but resolves to 17.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
==============================================================================
BUILD FAILED in 18s
38 actionable tasks: 3 executed, 35 up-to-date
My app/build.gradle: https://gist.github.com/christopheragnus/35c13d31976c889268b663cbf1654ead
My root /build.gradle: https://gist.github.com/christopheragnus/e6f506d6882ad37ce7656140a240f5bf
EDIT:
I tried changing /build.gradle to use version 16.2.0,
resolutionStrategy {
...
force 'com.google.firebase:firebase-iid:16.2.0'
}
This resulted in a different but same type of error:
> Task :tipsi-stripe:compileReleaseRenderscript FAILED
> Task :app:checkDevKernelReleaseClasspath FAILED
> Task :react-native-firebase:compileReleaseRenderscript FAILED
Could not resolve all files for configuration ':tipsi-stripe:releaseCompileClasspath'.
> Could not find com.google.android.gms:play-services-measurement-api:11.8.0.
...
> Could not find com.google.android.gms:play-services-measurement-base:11.8.0.
...
> Could not find com.google.android.gms:play-services-ads-identifier:11.8.0.

Gradle error: Error:Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes

To start off, this is the whole message:
Error:Error converting bytecode to dex: Cause: java.lang.RuntimeException: Exception parsing classes
Error:1 error; aborting
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with
non-zero exit value 1
This is what I have tried:
Restarting AS.
Restaring my computer.
Tried invaldiate caches and restart.
Rebuilt the project serveral times.
Earlier today I installed that latest java update, but it did not affect anything. After a couple of hours of coding, I added a jar file to my libs folder and wrote a class that used some of the classes from that library.
Now I can't seem to build the application at all anymore, even if comment out the class that uses the dependency.
Using Android Studio 2.0, Java 1.8.0_91-b14 and the library mysql-connector-java-5.1.38-bin
Edit:
I just tried removing the jar file, and now it builds just fine. So that's the thing causing the problem. Now how to solve it...
I think you need to add the following line in your app's build.grade file
defaultConfig {
...
multiDexEnabled true
}

Categories