AndroidStudio error that my app isn't compatible with Java 7 - android

Here is my Gradle build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "problemio.com.problemionew"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
My application compiled ok, but when I tried to run it, I got this error:
Any thoughts on what is going wrong here? My machine is set up for Java 6. When I tried to upgrade to Java 7 I got some errors so I had to revert to Java 6.

That error is due to problem in compilation which usually related to duplicated libraries or too many methods and classes. I guess that you are including google play services in you gradle . Try to use specific sub library from here https://developers.google.com/android/guides/setup.

This error
This error about for uses and give referance same classes.Look here

Related

How to change Platform-TOOLs

I'm building an app with Android Studio.
This is my grandle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.mcsolution.easymanagementandroid"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.0.0'
compile files('libs/gson-2.2.4.jar')
compile 'com.itextpdf:itextg:5.5.9'
compile 'com.android.support:cardview-v7:25.0.0'
}
If I try to start my application, I can use it never problem.
If I try to upen all view.xml file, I have this error:
The SDK Platform-TOOLs version (23.1) is too old to check APIs compiled with API 26; please update more....
How can I change Platform-TOOLs and fix my problem ?
Open SDK Manager
Go to system settings > Android SDK
Go to SDK Tools Tab
you will find Android SDK platform-Tools 23.1 and you will find an update available
just update it
As also reported in this link

Error while importing Eclipse project to Android Studio for support lib. v7

I am new to android studio And I'm trying to import eclipse project in android with few dependent android projects.
Please see below attached image and my message console for the error.
I have tried by changing API version to 24 which is latest nothing happen and again back to API 21 after one answer on SO.
Gradle version.
In wrapper I've 2.14.1 and in file I've 2.1.3
build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "package.name"
minSdkVersion 11
targetSdkVersion 21
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':comtwittersdkandroid_twitter')
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:21.2.0'
compile files('libs/httpclient-4.3.3.jar')
compile files('libs/httpcore-4.4.1.jar')
compile files('libs/httpmime-4.3.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/universal-image-loader-1.8.0.jar')
compile files('libs/zxing-1.7-core.jar')
compile files('libs/zxing-integration.jar')
}
I've tried adding jar instead of compile statement, it's not working.
Any help will be appreciated, thanks in advance.
Since you are using
compile 'com.google.android.gms:play-services:+'
you have a dependency with the support libraries v24 which require api 24 to compile.
You have to use:
compileSdkVersion 24
Thanks for your help, I finally break into the issue that is I have to delete com_crashlytics_export_strings.xml file from my project.
As I switch to API version 23 I removed http jars and added compile statements to build.gradle
One Important thing I've observed is "if you've dependent projects please cross check everything, as the main project mostly do not compile because of the issue with using same lib. in dependent projects or deprecated functions; as I have one for maps in one of my classes.
my build.gradle file
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 'Google Inc.:Google APIs:23'
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "package-name"
minSdkVersion 11
targetSdkVersion 21
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
compile('org.apache.httpcomponents:httpmime:4.3.6')
compile files('libs/universal-image-loader-1.8.0.jar')
compile files('libs/zxing-1.7-core.jar')
compile files('libs/zxing-integration.jar')
compile files('libs/gcm.jar')
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:appcompat-v7:23.2.0'
}
Thanks for the help. Answer to help anybody who faces same issue in the future.

Could not find class xxx referenced from method xxx when running app on API 19

I have a problem when I try to run my application on android device that uses API level 19 (Android 4.4.2). When I run the app on API>21 it works perfectly fine.
The errors I'm getting:
I tried setting buildToolsVersion to 19.1.0 instead of 23.0.3 but then I can't use MultiDex and I can't build the app without it.
here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "multisoft.testsurfaceview"
minSdkVersion 19
targetSdkVersion 19
versionCode 1
multiDexEnabled true
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:19.0.0'
compile files('/Users/admin/Desktop/Projects/testsurfaceview/libs/classes.jar')
}
I can't seem to find where the problem could be, any suggestions?
remove this compile files('/Users/admin/Desktop/Projects/testsurfaceview/libs/cl‌​asses.jar') from dependencies.
And just add the jar in libs folder and tried it..
see this link you will find your answer.
basically you did not configure multidex properly.
enter link description here

Compiler errors in Android API 24 source code

After downloading and installing the API 24 source code, I am seeing a large number of compiler errors in classes that have changes in API 24.
For example, the AccessibilityService class has hundreds of "Cannot resolve symbol" errors on variables, methods, imports etc.
I have tried deleting and redownloading sources multiple times to no avail. Is this a common occurrence with a new set of sources or did I do something wrong?
Edit:
Here is my app Gradle file, and I am using 'com.android.tools.build:gradle:2.1.0'
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.nyelito.dactyl"
minSdkVersion 23
targetSdkVersion 24
versionCode 10
versionName "1.2.2"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile(
[group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.4.1'],
)
provided 'org.glassfish:javax.annotation:10.0-b28'
compile('com.mikepenz:aboutlibraries:5.6.7#aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.github.medyo:android-about-page:1.0.5'
compile 'com.github.thepacific:adapter:1.0.5'
compile 'com.google.firebase:firebase-database:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.github.paolorotolo:appintro:4.0.0'
}
apply plugin: 'com.google.gms.google-services'
Here is a screenshot of what it looks like
When you change compileSdkVersion, you also need to change buildToolsVersion to something compatible. In this case
buildToolsVersion 24.0.2
#Code-Apprentice is right, you need to change buildToolsVersion with the major version number compatible with your compiled sdk version.
'android-24' requires JDK 1.8 or later to compile
https://developer.android.com/guide/platform/j8-jack.html
Also, I found you compiled with API 24, which needs JDK8. Please adds the following in your build.gradle
android {
...
defaultConfig {
...
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

"Cannot test obfuscated variants when compiling with jack" error when building Android app with Jack toolchain

I'm trying to enable the Jack toolchain in my Android project by following the steps in this article https://developer.android.com/preview/j8-jack.html but as soon as I add
android {
defaultConfig {
jackOptions {
enabled true
}
}
}
and run gradle clean, I get this error right away:
Cannot test obfuscated variants when compiling with jack
I tried it with a very simple Android project and I still get the same error. This is a sample gradle.build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 7
targetSdkVersion 23
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}
D'oh! The fix was really simple. Apparently Jack is not compatible with ProGuard and the line:
release {
minifyEnabled true
}
enables ProGuard, since it's now called "minify". Switching it to false fixes the issue... I just didn't see the line because it was in a different section...

Categories

Resources