While enabling jack I get following error
Error:Jar transformation: class files coming from an unsupported Java version Error:Execution failed for task
':app:transformClassesWithPreJackPackagedLibrariesForDebug'.
com.android.build.api.transform.TransformException: com.android.builder.core.JackToolchain$ToolchainException: Jack
compilation exception
My build gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "pl.develhopper.jaxygenaddclientlib"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
useLibrary 'org.apache.http.legacy'
jackOptions { // DEPRECATED
enabled true
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.8.2'
compile 'javax.xml.bind:jaxb-api:2.3.0'
testCompile 'junit:junit:4.12'
}
Doe anyone has an error like this? Where does it come from?
Jack is deprecated. If you want to use Java 8 you should update Android Studio to 3.0, mostly because you don't need Jack to use Java 8 with Android Studio 3.0
Jack is flawed, I couldn't even get it to compile when I used it. In my experience, the entire thing is buggy. Android Studio 3.0 comes with Java 8 support without Jack, meaning you don't need to deal with it.
if you already are using Android Studio 3, you can just remove the jack code in general. It isn't needed. If you are on a lower version, upgrade and then remove the jack code.
And if you read this:
Android Studio provides built-in support for using certain Java 8 language features and third-party libraries that use them. As shown in figure 1, the default toolchain implements the new language features by performing bytecode transformations, called desugar, on the output of the javac compiler. Jack is no longer supported, and you should first disable Jack to use the Java 8 support built into the default toolchain.
you'll see that AS 3 (the version referenced at the start of the site, not included in this answer for brevity) has support for Java 8 without jack. And since jack is deprecated and (in my experience) bugged, upgrading is your best option to get Java 8
Related
I've been struggling with getting RenderScript to work on my app with a TargetSDKVersion 26 and a minSDKVersion 21 getting an error at Gradle Sync:
Error:Execution failed for task ':app:compileDebugRenderscript'.
com.android.ide.common.process.ProcessException: Error while executing process /home/mail929/.android/sdk/build-tools/26.0.2/llvm-rs-cc with arguments {-O 3 -I /home/mail929/.android/sdk/build-tools/26.0.2/renderscript/include/ -I /home/mail929/.android/sdk/build-tools/26.0.2/renderscript/clang-include/ -p /home/mail929/Code/Android/SmartME/app/build/generated/source/rs/debug -o /home/mail929/Code/Android/SmartME/app/build/generated/res/rs/debug/raw -target-api 21 /home/mail929/Code/Android/SmartME/app/src/main/rs/combine.rs}
Eventually I noticed at the bottom of the documentation page:
Graphics Functions and Types
The graphics subsystem of RenderScript was removed at API level 23.
Does this mean I can't use RenderScript at all? If so are there any good alternatives?
Here is my complete build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "edu.marquette.mcw.smartme"
minSdkVersion 21
targetSdkVersion 26
versionCode 4
versionName "2rc1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
renderscriptTargetApi 18
renderscriptSupportModeEnabled false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:cardview-v7:26.0.0'
testCompile 'junit:junit:4.12'
}
No, Renderscript hasn't been completely deprecated, only the graphics functionality which operated on some OpenGL type constructs directly. Since it was more or less doing the same thing available in OpenGL, it was dropped and instead you can exchange textures with OpenGL.
The combination of minSdkVersion and renderscriptTargetApi in your build.gradle will result in the minSdkVersion being used for the Renderscript target API. The way this works can get really odd. Unless you absolutely need something in the android.renderscript framework package, use the support library version by setting renderscriptSupportModeEnabled to true. This may also help resolve whatever issue you are seeing. If it doesn't, try to provide more details from the build log.
Well I actually decided to manually run the command to see what was wrong and recevied the following error:
error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
I fixed this by installing ncurses-compat-libs on Fedora and Gradle Sync completes successfully
So, the title pretty much sums up my problem. Anyone know how to fix it? Last time I build apk, it work fine on AS 2.X, but, I'm now developing with Kotlin so, I have to use AS 3.0.
I use AS 3.0 Canary 7 (This project is a fresh project)
This is my dummy class in my library (Stored in "domain".library.mylibrary)
class Test {
fun hello(): String {
return "hello"
}
}
And this is my (mylibrary) gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" //Declared in project level gradle: ext.kotlin_version = '1.1.3-2'
}
My gradlew.bat clean build --info log: https://pastebin.com/bfTZ5s4e
Android Studio does not generate a jar by default, but rather an AAR file. If you want to get a jar output, you need to implement apply plugin: 'maven-publish' on top of your mylibrary/gradle.build file and read the following document: Chapter 36. Maven Publishing (new)
Another note, is that I would suggest you not to use ProGuard directly on your release artifact, but rather provide a consumer ProGuard file and let the users of your library to handle that task, otherwise they will have a hard time referencing obfuscated code. Read my answer on this here
While the build task may generate an output, it is known that the assemble task (or assembleRelease) is the one that will generate your aar output.
Try running the following command:
./gradlew clean assembleRelease
and check the output in /mylibrary/build/outputs/apk/release/ if I am not mistaken.
Android studio has automatically update the following components to API 26:
ROM - SDK to API 26
Android SDK Build-Tools 26
Android Emulator 26.0.3
Android SDK Platforms-Tools 26.0.0
Android SDK Tools 26.0.2
My gradle 2.3.3:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "com.mycompany.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 4
versionName "0.0.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
/////////If I change it to 26.0.0 it gives errors.///////////
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
/////////////////////////////////////////////////////////////
testCompile 'junit:junit:4.12'
}
I have two questions (see commented line in Gradle):
How can I know the latest version of these libraries (I simply throw random numbers and try to up them until I found the latest version).
In the excluded group there is 'com.android.support', if I delete that do I need to specify those libraries? I see many people including 'com.android.support' libraries this way so there is a reason I guess to do so.
I searched in developer.android.com and the latest version is 24.2.0 (so really old I have been using 25.3.1).
If you really want to use the 26 version you could use the + character at the end of your dependencies.
compile 'com.android.support:appcompat-v7:26+'
This way, grade will take the latest version beginning with 26.?.? of your dependency. But you will get a warning from Android Studio, because between two different versions the behavior could eventually change and then produce random effect.
To know the latest version, just take a look here : https://developer.android.com/topic/libraries/support-library/revisions.html
And to finish, if you include 'com.android.support', you will include the whole library. And you certainly not need all the stuff included. If you only use recycler view just add :
compile 'com.android.support:recyclerview-v7:26.0.0-beta2'
Check https://developer.android.com/topic/libraries/support-library/revisions.html and set language to English at footer to check latest version of support library. Currently is 25.4.0 (stable) or 26.0.0 (beta 2)
Try this:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Thanks for reporting your issue.upcoming 6.0.0 release includes support for Java 8 features, therefore in order to run it (or any of the betas) you need to upgrade your project to include Java 8 support by adding this into you app's gradle file:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
I'm somewhat new to android dev, so i'm having some issues developing for multiple API's. When I created my project, I set the minimum API level to 18 which isn't even supported anymore (according to a wiki: https://en.wikipedia.org/wiki/Android_version_history)
I tested the installation of an APK on two different phones, both were API 24, and there were no issues. However, my associate with API 19 cannot install the application. Apparently it gave him the informative error of "App not installed."
For testing purposes, I created a new project, and without adding any code (Leaving only Android Studio's generated "Hello World" label), generated a signed APK, then sent that out to my associate. He failed to install that as well.
The only other thing of note was that I played around with enabling "jack." I was testing out some random source code which required it. I wonder if that would cause problems? That is hard to believe with an empty project.
More specifically, I had this error when testing the source code mentioned above "Error:Jack is required to support java 8 language features. Either enable Jack or remove sourceCompatibility JavaVersion.VERSION_1_8." So, I enabled Jack, of course.
Here is the build.gradle (if that helps?)
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.random.name"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Any thoughts are highly appreciated!
Looks like you're trying to use java 8 in your project, java 8 doesn't work on API level 18 also you need to enable jack toolchain for that
source: https://developer.android.com/guide/platform/j8-jack.html
though if you would like to use java 8 features you can use retrolambda with gradle
https://github.com/evant/gradle-retrolambda
For now if you're not using any java 8 features, then just change source compatibility in your gradle file to java 7 instead of java 8 and it should work fine.
use this
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
instead of
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
it can be pasted in your gradle file like:
android {
...
defaultConfig {
...
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
I added 5 jar files of Apache POI so that I can save an text as .docx document but I can't run the application first I had 210 error in the grade now i have this error can someone please help me ..!? i followed this example
https://www.tutorialspoint.com/apache_poi_word/apache_poi_word_quick_guide.htm
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.mike.textword"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile files('libs/dom4j-1.6.jar')
compile files('libs/poi-3.16-beta2.jar')
compile files('libs/poi-ooxml-3.16-beta2.jar')
compile files('libs/poi-ooxml-schemas-3.16-beta2.jar')
compile files('libs/xmlbeans-2.6.0.jar')
compile 'com.android.support:multidex:1.0.1'
}
and now i have this error!
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class
Currently Apache POI will not work on your Android Phone out of the box due to various problems that you will run into when using the libraries from Apache POI directly. Android is more strict about duplicate classes as part of the jar-files and unfortunately XmlBeans has such duplicate classes in it's jar-file.
There are two projects that try to make it possible to use Apache POI on Android:
https://github.com/andruhon/android5xlsx (for Android 5) and https://github.com/andruhon/AndroidReadXLSX (for Android 4), both are currently still based on Apache POI 3.12
https://github.com/centic9/poi-on-android/ (for Android 5, maintained by me), which can be more easily recompiled with newer versions of POI, e.g. it uses 3.16-beta2 currently
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class
It means that you are adding this class twice or more.
Check all you jars files to remove it.