I am trying to import a project in Android Studio. This code supposedly works but I cannot seem to be able to build the project. This is the error that is produced when I am trying to build:
Error:Execution failed for task
':openCVLibrary2410:compileReleaseJava'.
Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to
point to the according directory.
I have searched for a solution, but what I found was was either referring to eclipse or changing the jdk position for
File > other Settings > Default Project Structure
Which is not a valid solution for me because I checked my previous Android Studio Projects and all have the same position
This is the stacktrace:
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':openCVLibrary2410:compileReleaseJava'.
mainProject Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
FaceRecognition Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "eu.upcom.recred.facerec"
minSdkVersion 9
targetSdkVersion 9
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile files('libs/javacpp.jar')
compile files('libs/javacv.jar')
compile project(':openCVLibrary2410')
}
openCV2410 gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
While I was posting here the gradle files my eye caught something. I changed the build tools version from 'com.android.tools.build:gradle:1.1.0' to 'com.android.tools.build:gradle:2.2.2'and now it is building as it should
I had same problem, Here is problem on Java path. You can check you have set path of your java or JDK in system variable or not click Environment variable
Also check your Java JDK version.
Also this link have all details of How to set path.
I suggest to you can use this solution. It will be help to resolve your problem..
Related
I try to move android TV app to Android studio. When I try to compile it, I had some import errors. I couldn't find the dependency that I can add to build.gradle to fix these problem. The list of the imports are:
import android.media.tv.TvContentRatingSystemInfo;
import android.media.tv.TvContract.WatchedPrograms;
import com.android.tv.tuner.data.nano.Track.AtscCaptionTrack;
import com.android.tv.tuner.data.nano.Track.AtscAudioTrack;
import com.android.tv.tuner.data.nano.Channel;
The build.gradle is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.android.tv"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "libtunertvinput_jni"
}
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/usbtuner-res']
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/exoplayer.jar')
compile project(':common')
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.android.support:support-annotations:+'
}
You can't import these because they have #SystemApi annotation. You can check this for the source code of TvContentRatingSystemInfo. I have also checked WatchedPrograms and it also has #SystemApi annotation. I have not checked the other three.
You need to be system app to access these. As you can see here, you need to push your app in the the \system\ folder. You can find detailed information about AOSP build system here.
Solution :
Changing your android.jar to the .jar in this github should enable you to access system API. The reason is your standard android.jar doesn't have system API. So you need to get framework.jar (by adb pull) from emulator and combine it with core.jar then you can have new android.jar which contains system API (system methods and classes are available in the framework.jar from emulator).
Moreover, you should push your apk to \system\priv-app\ folder to access some system API but I don't know why I can access system API without pushing my apk to \system\priv-app\ when I use .jar from that github account.
I feel like I don't write quite clearly but at least now you have more understandings of what you're facing.
android.media.tv and com.android.tv are part of Android SDK. So you don't need to include any additional libraries in gradle.build file.
Just make sure to:
Update your SDK tools to version 24.0.0 or higher
and
Update your SDK with Android 5.0 (API 21) or higher
Example,
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.tvapp"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
}
use this in your dependencies "com.android.support:support-media-compat:26.0.2"
and also use tool version "26.0.1"
compiled SDK version 26.
You can add dependencies in app level gradle.
compile 'com.google.android.libraries.tv:companionlibrary:0.1'
I have two projects: library and app. I have previously uploaded library to jCentre, and library is listed as an external dependency of app in its build.gradle file. Recently I published a newer version of library and updated the dependency version code in app's build.gradle file, but when I did this Android Studio could no longer find any of the classes from library.
To test the library, I created an entirely new project and added library as a dependency. In this scenario Android Studio finds the classes just fine. I've compared every line of the build.gradle files: They have the same min and target SDK version, they have the same proguard config, they're literally identical. They projects are also using the exact same version of the android plugin and the exact same gradle version.
I also tried entirely deleting app from my machine and re-checked it out from git. This did not solve the problem. I've tried all the usual steps of cleaning the project and rebuilding the project, deleting all build files, invalidating caches, etc.
So can anyone tell me why Android Studio cannot find any of the library classes after upgrading the dependency version?
Here is the gradle.build file in the new test project:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 24
versionCode 11
versionName "3.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.matthew-tamlin:android-utilities:2.1.0' // this is library
}
Here's the build.gradle file in the app project:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 11
targetSdkVersion 24
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.matthew-tamlin:android-utilities:2.1.0' // this is library
}
You can see that they're virtually identical, so why can one project find the classes from the library but the other cannot?
So I never discovered why this is an issue, but I found a workaround. I created a new project in Android Studio and copied all the src directories and build.gradle files from the existing project. I also copied the hidden git folder and all git ignore files. I didn't copy the gradle wrapper, the gradle file or the generated builds. I don't know why this fixed the problem, it must be a bug in gradle or Android Studio.
I build a player based VLC,and when I want to build a verson for Android 6.0,player can't start on Android 6.0 device.Here are the log:Can't load vlcjni library:java.lang.UnsatisfiedLinkError:dlopen failed:/data/app/lib/arm/libvlcjni.so: has text relocations.
And I have tried so many ways to solve it,but I haven't solve it yet.
I hope anyone can tell me about the problem.
Here is similar question and answers: libavcodec.so: has text relocations
Today, I got the same error messages when testing my app with Android 6.0 on a Nexus 6 (Motorola). I solved my issue by checking the targetSDKVersion in the manifest file. Using "22" and not "23" as targetSDKVersion solved it. (See below)
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="22" />
I also checked the build.gradle files for compile version and targetSDKversion:
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
minSdkVersion 15
targetSdkVersion 22
}
Hope this will help you. However, this is just a short term workaround for now, I hope that we will get some feedback from metaio though.
Regards, christin
I only had to create a libs folder in my Android library, and then move the library files from the jniLibs folder to the libs folder. I believe this may have to do with the newer version of Gradle and build tools. That way, you don't have to downgrade your build tools/Gradle.
UPDATE:
I was able to build with the following build.gradle script for vlc-android. I needed the following updated versions. This allows me to build with SDK version 24, with build tools 24, and gradle version 2.2.0. See if this works for you.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'org.ajoberstar:gradle-git:1.3.2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
//noinspection GradleCompatible
compile "com.android.support:support-v4:25.2.0"
compile 'com.android.support:support-annotations:25.2.0'
}
I'm new to Android and I can't get my first app to run. Whenever I try, it's throwing this error:
Android gradle :app:packageDebug FAILED: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.
I googled it and I found many questions there. As many said, this problem is probably due to the fact that I have multiple dependencies on BouncyCastle in my project. I tryed to remove the .gradle folder both in my project and in my local folder so I could download again the jars from the repository but nothing has changed. I also double checked that my JAVA_HOME is set and it's pointing to a 1.7 version. I tryed to gradle :app:clean and gradle :app:dependencies to see if I was missing something but still... I can't see any dependency from BouncyCastle... Can anybody help me?
Also, this problem occured without me changing any code... The app successfully worked yesterday and now is giving me this error... I don't get it. Thank you.
EDIT
gradle.build
Top-level:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Module app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.aurasphere.provaactionbar"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile project(':volley')
compile files('libs/gson-2.2.2.jar')
}
Module volley:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.14.+'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion = '21.1.0'
}
apply from: 'rules.gradle'
rules.gradle for module volley:
apply plugin: 'com.android.library'
I've solved this problem myself just by changing the JDK I was using from x32 to x64 and now is compiling correctly.
I tried many options from google and stackoverflow.
Android studio 0.4.6 and aa 2.7.1.
My build.gradle looks like this
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
ext.daggerVersion = '1.0.0';
ext.androidAnnotationsVersion = '2.7.1';
configurations {
apt
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
apt "com.squareup.dagger:dagger-compiler:${daggerVersion}"
compile "com.squareup.dagger:dagger:${daggerVersion}"
}
I've checked Activities_ in AndroidManifest.xml too.
If this quesion were not banned due to other "similar" questions I would prefer answers from people who did it with exacly the same as version. I know there will be next version's and maybe new questions but this looks litle tricky imho. Even though android development with aa is very robust.
"sync project with gradle files", clean, rebuild etc brings no effect.
EDIT:
I tryied with
ext.daggerVersion = '1.2.0';
ext.androidAnnotationsVersion = '3.0.1';
but it brings no result.
After switching to:
classpath 'com.android.tools.build:gradle:0.8.+'
and
ext.daggerVersion = '1.2.0';
it builds succesfully but outputs with:
Default Activity not found
I checked Error: Default Activity Not Found with no effect.
It looks like you need to add the android-apt dependency within the BuildScript dependencies and let gradle know to use it as a plugin.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.2'
}
}
apply plugin: 'android'
apply plugin: 'android-apt'
This is my apt config section, you may need other settings but this should get you started
apt {
arguments {
resourcePackageName android.defaultConfig.packageName
androidManifestFile variant.processResources.manifestFile
}
}
Lot's more info here: https://bitbucket.org/hvisser/android-apt