React-Native ':app:compileDebugJavaWithJavac' Error (Android Studio) - java

Recently dove into the world of React-Native and got roadblocked immediately. Bought a course from Udemy called The Complete React Native and Redux Course and got stuck trying to compile my first application.
I've tried a bunch of different solutions and have gone through a variety of different errors so its come to the point where I have to make my first stackoverflow post. Going to post a bunch of my current settings below as well as the error im receiving.
Error
My Configuations
Java SDK/JRE's I have installed
JAVA_HOME = C:\Program Files\Java\jdk1.8.0_151
ANDROID_HOME = C:\Users\Danny\AppData\Local\Android\sdk
PATH = C:\Users\Danny\AppData\Roaming\cabal\bin;C:\Users\Danny\AppData\Roaming\npm;
React Native Properties
React-Native Version
Android Studio Properties
Project Structure
SDK/JDK Location
Installed SDK Tools
Installed SDK's
gradle-wrapper.properties
#Mon Dec 11 21:41:46 EST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-rc-2-
all.zip
build.gradle (Module:app)
android {
compileSdkVersion 23
buildToolsVersion '25.0.1'
defaultConfig {
applicationId "com.albums"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
build.gradle (Project: albums)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
}
}
In the course im using the instructor says to use the NEXUS 5 API 23, incase that helps. Gradle builds within Android Studio no errors.
Thanks for any and all help

Solved.
Deleted my project, recreated it with react-native init ProjectName, ran AVD, compiled project through terminal. I think I altered too many configurations in my old one and needed to recreate it.

Related

I can't run an android app because of a seemingly missing unknown parent resource? [duplicate]

I've always programmed Android with Eclipse and decided to start migrating to Android Studio. I decided to use the same SDK I already had for Eclipse, then:
Started a new project
Set minimum SDK 4.0 (API Level 14)
Choose Blank Activity option
Used Default names for Activity Name and Layout Name
Hit Finish
After a few seconds Gradle finishes the build, and it throws me two errors with the following messages in file Teste4\app\build\intermediates/exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v23\values-v23.xml:
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Under File -> Project Structure -> Modules: app (left column) -> Properties tab, I have the following versions set up:
"Compile Sdk Version": Android 5.1 (API Level 22)
"Build Tools Version": 23.0.2
What should I do in order to fix this?
I already tried what was suggested in Stack Overflow question appcompat-v7:21.0.0': No resource found that matches the given name: attr 'android:actionModeShareDrawable', but it didn't work.
Your compile SDK version must match the support library's major version.
Since you are using version 23 of the support library, you need to compile against version 23 of the Android SDK.
Alternatively you can continue compiling against version 22 of the Android SDK by switching to the latest support library v22.
This happens because after updates Android Studio uses API version 23 by default.
The following worked for me:
Press Ctrl + Shift + Alt + S to get to the project structure page. Go to the properties tab and change 23.0.0 to 22.0.1 (or equivalent to what you were using earlier) in the build tool area and rebuild your project.
If that doesn't work, go to gradle:app and then
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
Edit v7:23.0.0 to v7:22.2.1 as shown above and sync gradle. This will definitely work.
When you update your Android Studio, it uses API version 23 by default,
which is the main reason for its occurrence. So,
At first, check your AppCompat version in build.gradle(Module:app)
That is,
If after changing to 23 there occurs an error then just download
Compile Sdk Version to API 23, and Build Tools Version to 23.0.0
from SDK Manager. If already downloaded then:
1. Go to SDK Manager and
2. Under Project Structure, change *Compile SDK Version* to API 23, and *Build Tools Version* to 23.0.0
Click the SDK Manager Button and open the dialog.
Click SDK Platform and check if Android 6.0 is downloaded or not.
if not, then download that first. After completing the download, click Apply.
Now you need to apply changes to your project from setting.
Then press Ctrl + Alt + Shift + S to open setting
Click the app from the list.
Click properties
Change your Compile SDK Version to API 23
Change your Build Tools Version to 23.0.0
Don't forget to rebuild your project.
Then your error will be gone.
If you've tried to change target to a previous GooglePlayServices or AppCompatv7 version and it doesn't work, check if you have any project-libraries dependency, this project will be targeting the latest version of any of these libraries. It happened to me with the Google Maps Utils Library project:
replace:
compile 'com.google.android.gms:play-services:+'
to
compile 'com.google.android.gms:play-services:8.3.0'
Then you can continue full targeting API 22
If it still doesn't compile, sometimes is useful to set compileSdkVersion API to 23 and targetSdkVersion to 22.
I agree with the previous answer. Your compile SDK version must match the support library. Here is what I did.
You can go to SDK Manager and under SDK Platform, install the Android 5.X with API level 23.
Under Project Structure, change compile SDK Version to API 23, and Build Tools Version to 23.0.0
Then it should build without problem.
You need to set compileSdkVersion to 23.
Since API 23 Android removed the deprecated Apache Http packages, so if you use them for server requests, you'll need to add useLibrary 'org.apache.http.legacy' to build.gradle as stated in this link:
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
...
//only if you use Apache packages
useLibrary 'org.apache.http.legacy'
}
This issue is raised because now the compile SDK version must match the Android Support library's major version.
In my case i have the Android Support Library version 23, so i had to compile against the Android SDK version 23, and I had to change this in my build.gradle file:
Well some of you will need to install the SDK, Android 6.0 (API 23)
and donĀ“t forget to Sync project with gradle files
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
defaultConfig {
applicationId ""
minSdkVersion 14
targetSdkVersion 22
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.google.code.gson:gson:2.3.1'
compile 'com.android.support:recyclerview-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'
}
I found the solution, Problem started when I updated sdk, after that I used different buildToolsVersion ('22.0.1') and I was using different support library like compile 'com.android.support:appcompat-v7:23.0.0', showing you in image below
This was raising problem of "android.widget.Material..."
Then I used same version for support library like compile 'com.android.support:appcompat-v7:22.0.1' and its DONE. (Showing you in below screenshot)
You should compile your project with latest version so update & install from your SDK. Sync your project with sync project with Gradle file Button.
You can also continue with the existing version but check it installed properly below image indicate to API 22 that is properly installed.
And sync your project if needed.
it may help.
As pointed out by Tanis.7x, the support library version (23) does not match the targetSdkVersion (22)
You can fix this by doing the following:
In the build.grade file of your app module, change the following line of code
compile 'com.android.support:appcompat-v7:23.0.0'
To
compile 'com.android.support:appcompat-v7:22.+'
This will use the latest version of the appcompat version that is compatible with SdkVersion 22.
Your compile SDK version must match the support library major version. This is the solution to your problem. You can check it easily in your Gradle Scripts in build.gradle file.
Fx: if your compileSdkVersion is 23 your compile library must start at 23.
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 340
versionName "3.4.0"
}
dependencies {
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
}
And always check that your Android Studoi has the supported API Level. You can check it in your Android SDK, like this:
In my case it was an higher version of Google-play-services. I set them to 7.0.0 (not 8.x) and all was ok.
I wanted to downgrade from API 23 to 22 and got this error. I had to change all build.gradle files in a project in order to compile.
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.yourapp.app"
minSdkVersion 14
targetSdkVersion 22
}
...
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.google.android.gms:play-services-gcm:10.0.1'
}
This is what helped me: Adding specific android platform
What should be done is the following... In my case it was cordova but the same is relevant for ionic, phonegap and other frameworks like these:
list all platforms installed for your project: cordova platform list. You'll see something like this:
remove the android platform: cordova platform remove android.
then add the specific android platform: cordova platform add android#5.0.0.
Good luck! :)
I got the same problems. I solved my problem by updating gradle.build for each sub-module to latest compiler version.
Another solution :
navigate to
\sdk\extras\android\m2repository\com\android\support\appcompat-v7\23.x.x
open .aar file with 7-zip or winrar , in res folder remove values-23 folder and save changes .
on module: app (Gradle)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.namepack.nameappxxxxx"
minSdkVersion 16
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:21.0.3'
}
project: nameAppXXXX (Gradle)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
}
allprojects {
repositories {
jcenter()
}
}
and edit your activity of AppCompatActivity to for example Activity:
package com.namepack.nameappxxxxx;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
public class NameClass extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
}
}
Everything is great but none of you explained where to download the SDK build tools
Make sure that all these are in upto date.
Upgrade Android Studio.
I had this issue with Android Studio 1.3.1 and none of the other answers worked for me, but after updating to 1.5.1 there were no problems.
If you are using phonegap(cross-platform) and got same issue above,
just remove the android platform using below command.
phonegap platform remove android
And add it again.
phonegap platform add android
Then problem solved for me.
If you are getting errors even after downloading the newest SDK and Android Studio, here is what I did:
Download the most recent SDK
Open file-Project structure (Ctrl + Alt + Shift + S)
In modules, select app
In the properties tab: Change compile SDK version to API 23 Android 6.0 marshmallow (latest)
I hope it helps someone so that he won't suffer like I did for these couple of days.
As others have already mentioned your compile sdk version must match your support library's major version. This is however, also relevant for subprojects should you have any.
In case you do, you can set your subprojects compile sdk versions with the following script:
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
Add this script in your root build.gradle file.

Gradle sync failed: Unable to find method

I try to import a project in Android studio. When importing it, i've got an Error with Gradle :
Gradle sync failed: Unable to find method
'org.gradle.api.artifacts.Configuration.setExtendsFrom(Ljava/lang/Iterable;)Lorg/gradle/api/artifacts/Configuration;'.
I have tried :
Re-download dependencies and sync project: Fail (same error).
Stop Gradle build processes: Fail (same error).
Delete the .graddle in the home directory: Fail (same error).
Invalidate cache and restart Fail (same error).
Uninstall and reinstall Android studio and SDK: Fail (same error).
/build.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:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
/app/build.gradle
apply plugin: 'com.android.application'
//apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'xxx.xxx.xxx'
minSdkVersion 17
targetSdkVersion 17
versionCode 1
versionName '1.0'
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildPB {
debuggable false
jniDebuggable false
renderscriptDebuggable false
zipAlignEnabled true
}
}
productFlavors {
}
// lintOptions {
// abortOnError false
// }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// You must install or update the Support Repository through the SDK manager to use this dependency.
compile ('org.simpleframework:simple-xml:2.7.1') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
compile 'net.sf.opencsv:opencsv:2.3'
compile 'de.greenrobot:greendao:1.3.7'
// You must install or update the Support Repository through the SDK manager to use this dependency.
// compile 'com.android.support:support-v4:19.+'
}
I fixed the error by changing the following things.
Open the file under your-app-project\your-app-name\gradle\wrapper\gradle-wrapper.properties
replace the old URL path by this one:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Rename the folder name from "...\1.12" to your-app-project\your-app-name\.gradle\2.10
Change the classpath of your-app-project\your-app-name\build.gradle to
classpath 'com.android.tools.build:gradle:2.1.2'
Replace runProguard of your-app-project\your-app-name\app\build.gradle by minifyEnabled
Click Retry on the error reminder or Reopen your Android Studio and project.
I am using the latest versions of Android Studio and Gradle.
edit Project >> App >> gradle >> wrapper >> gradle-wrapper.properties
distributionUrl=http\://services.gradle.org/distributions/gradle-2.10-bin.zip
rebuild the project (restart ide in your mind)
Project >> App >> gradle >> wrapper >> gradle-wrapper.properties
https\://services.gradle.org/distributions/gradle-4.1-all.zip
This will surely work. I was having same issue. Solved by this.
This issue appears when I updated my android studio to 3.1.1
1.
I have resolved it by changing:
classpath 'com.android.tools.build:gradle:3.1.1'
in build.gradle (project)
2.
change:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
in gradle-wrapper.properties.
(you can check it in explorer C:\Program Files\Android\Android Studio\gradle\gradle-4.4)
I faced similar issue and i resolved it by
Android Studio Version 3.0.1
1.Change the classpath of your-app-project\your-app-name\build.gradle to classpath 'com.android.tools.build:gradle:3.0.1'.
2.Replace the old URL path by this one: distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
My gradle file was of version 4.1
ie; file in following location:(may differ slightly in your machine)
C:\Program Files\Android\Android Studio\gradle\gradle-4.1
Under gradle->gradle-wrapper.properties
replacing
distributionUrl=https\\://services.gradle.org/distributions/gradle-2.2.1-all.zip
with
distributionUrl=https\\://services.gradle.org/distributions/gradle-4.1-all.zip
solved the issue.
This issue happened to me today with Android Studio 2.2 Beta2 on Windows 7 64-bit.
None of the solutions mentioned helped. Finally I was able to resolve the issue by re-importing my project.
For me the solution was to open Settings -> Build, Execution, Deployment -> Gradle and check "Use default gradle wrapper (recommended)".
I was able to copy over the /.gradle folder from a new Android project into the one that was having the problem. Then I restarted Android Studio and did a clean/build. This resolved my issue.
After 1 hour R&D Not Solution as worked for me...
But still i have solution follow this its work 100
step 1: upgrade your build.gradle(Project:<your project name>)
Example : classpath 'com.android.tools.build:gradle:2.1.3' // old gradle file
classpath 'com.android.tools.build:gradle:2.3.1' // upgraded file
OR
classpath 'com.android.tools.build:gradle:3.1.0'
Step 2 : Upgrade compileSdkVersion buildToolsVersion
Example : compileSdkVersion 23 buildToolsVersion "23.0.3 // old api's
compileSdkVersion 25 buildToolsVersion "25.0.2" // upgraded api's
Step 3: upgrade gradle-wrapper.properties
Example : distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip // old or any version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip // new or any version
Step 4 : finally goto build>rebuild project...
......End #Ambilpura
The answer is partially reduntant, but it's for those who are confused with what version of gradle distribution to add.
It's the gradle version that's installed on your machine.
Ex:
Check your gradle version by:
"gradle -v" (mine was 5.4.1)
Update the file "your-app-project\your-app-name\gradle\wrapper\gradle-wrapper.properties" with
distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip
And done! It solved the problem for me.

Gradle is build with errors in android studio

I am using android studio.This is the error suddenly I got when building gradle. Earlier it was working correctly. I close the android studio and re-build the gradle. But doesn't fix the error. I clean and rebuild the gradle.
Can you solve the problem.
Error:org.gradle.api.internal.changedetection.state.DefaultFileCollectionSnapshotter$FileCollectionSnapshotImpl cannot be cast to org.gradle.api.internal.changedetection.state.OutputFilesCollectionSnapshotter$OutputFilesSnapshot
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Following display my build.gradle information
classpath 'com.android.tools.build:gradle:1.5.0'
pply plugin: 'com.android.application'
compileSdkVersion 23
buildToolsVersion "23.0.2"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
Gradle may be not found. Try to change gradle version and update it with your gradle version like in project :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
and this one in module of gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.yourproject"
minSdkVersion 15
targetSdkVersion 23
versionCode 14
versionName '1.4'
}

Failed to set up SDK: Error:Module 'app': platform 'Google Inc.:Google APIs:21' not found

Failed to set up SDK: Error:Module 'app': platform 'Google Inc.:Google APIs:21' not found.
At a complete loss as to why this isn't working. Attempted to update my SDK to 23 but realized I wasn't prepared to deal with all the new deprecations, etc., so I reverted to an older version on Mercurial. I've done literally nothing else, and the reversion should have solved everything. Unfortunately, I'm stuck unable to connect my app and build it. I've even reinstalled Android Studio from scratch, but I continue to receive the same warning and my app won't build at all. What could possibly be going wrong?
Here is my build gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.elgami.customizer"
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
//runProguard false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.ogaclejapan.smarttablayout:library:1.5.0#aar'
compile 'com.github.antonyt:InfiniteViewPager:v1.0.0'
compile 'com.android.support:appcompat-v7:22.2.0'
// recyclerview
compile 'com.android.support:recyclerview-v7:23.1.1'
// google analytics
compile 'com.google.android.gms:play-services-analytics:8.3.0'
// pager sliding strip
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
// http library (for using beanstream REST)
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
// amaazon S3 uploads
compile 'com.amazonaws:aws-android-sdk-s3:2.1.+'
// paypal purchasing
compile files('libs/PayPalAndroidSDK-2.7.1.jar')
// Module dependency on ParseLoginUI library sources
compile project(':ParseLoginUI')
// Parse libs
compile files('libs/ParseCrashReporting-1.9.2.jar')
compile files('libs/Parse-1.9.1.jar')
compile files('libs/ParseFacebookUtilsV4-1.9.1.jar')
// android support v4
compile files('libs/android-support-v4.jar')
// facebook SDK
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
//butterknife
compile 'com.jakewharton:butterknife:6.1.0'
// Subsampling-scale-image-view (for templating)
//compile 'com.davemorrissey.labs:subsampling-scale-image-view:3.1.4'
compile files('libs/AppRater.jar')
}
You can use compileSdkVersion 21 instead of yours .
android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
defaultConfig {
applicationId "com.elgami.customizer"
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
//runProguard false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
The (currently accepted) answer that suggest replacing Google Inc.:Google APIs:21 with 21 is NOT suitable if you have some legacy app still using Google Map v1 (for example).
If you are in this situation you REALLY need to compile against Google Inc.:Google APIs:21 or 23 etc...
The solution here is to
Step 1
Open the old SDK manager interface clicking the Launch Standalone SDK Manager link below the Android Studio SDK Manager or by executing ${ANDROID_SDK_DIR}/tools/android sdk from command line to open it directly.
Then locate Google APIs for the SDK version you need and install it:
That package is hidden, for some reason, inside Android Studio and I expect Google will remove it at some point. Currently the SDK 24 one (Marshmallow) is available but the 25 (Nougat) is not, they may add it in the future, or not. We will have to wait and see.
If you are in this situation and Google decide to stop providing it you'll have to rewrite the functionality using maps v2.
Step 2
Even after doing this and cleaning + gradle resync you'll get this error From Android Studio:
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.
But it will compile if you try to do it from the command line (./gradlew assembleDebug).
The reason has apparently something to do with the Android Studio embedded Java JRE.
To make it compile inside Android Studio open the Project Structure from Android Studio and provide a custom path for a JDK you installed on your system (you must install a OpenJDK / OracleJDK on your computer).
NOTE: it may be needed to navigate to the location instead of copying the path for Android studio to take the change. Do not pick the jre directory, pick the JDK (folder containing jre).
WARNING: this change is not specific to the project but will be applied to Android Studio itself and used on any other project.
When it failed for me I downloaded Google API's, just as #Daniel Segato explains, which is the right thing to do, and still I got the message once and again and again.
Until I did this. I opened the module's settings (Ctrl + Alt + Shift + S or File > Project Structure) and, for my module, I changed the Compile Sdk Version option to any other from the list. I resynchornized gradle and then changed the option back to Google APIs (API 23). And then it worked! It's really really really nasty of Android Studio not to recognize the SDK until you change it in that dialog box. But this only happened to me once. Other times it was enough just to download the proper Google API and there you go! But this is nasty.
my problem was in my build.gradle ! when I opened It was like this :
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.pixelnx.sam.allinone_room"
minSdkVersion 21
targetSdkVersion 21
How fixed it ?!
remove 'Google Inc.:Google APIs:21' and write 29 instead of it
2.set 29 for targetSdkVersion
RESULT :
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.pixelnx.sam.allinone_room"
minSdkVersion 21
targetSdkVersion 29

Importing Facebook library in Android Studio: Could not find property 'ANDROID_BUILD_SDK_VERSION'

I want to import a library project into my app but whenever I try to do so , Android Studio doesn't recognise it
It also gives me errors in build.gradle ..
The Library is : PagerSlidingTabStrip ....
Here are some pictures :
I have been trying to make it work for 3 days so far !!
Please Help Me :)
EDIT:
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:19.0.0'
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 8
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
apply from: 'https://raw.github.com/chrisbanes/gradle-mvn-push/master/gradle-mvn-push.gradle'
EDIT2 :
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':Sahertoday'.
> Could not resolve all dependencies for configuration ':Sahertoday:_debugCompile'.
> Could not find com.astuetz:pagerslidingtabstrip:1.0.1.
Required by:
Saher-3:Sahertoday:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
First of all, you can add this dependency to your project, without compiling the lib locally.
dependencies {
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
}
Otherwise if you would like to compile this lib locally, you have to define these keys in gradle.properties in the root.
ANDROID_BUILD_TARGET_SDK_VERSION=19
ANDROID_BUILD_TOOLS_VERSION=19
ANDROID_BUILD_SDK_VERSION=19
EDIT
There is also a GUI way for doing this. It is accessed by selecting the module facebook in the project tree and pressing f4. Also you can just right-click the facebook and go to Open Module Settings near the bottom. It is shown in the pictures. The numbers in the picture are top sdk version at the time of writing.
There is a simpler solution.
The constants like ANDROID_BUILD_SDK_VERSION can be replaced with normal version "numbers". So instead of
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion 8
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
..file can look like this:
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 15
targetSdkVersion 19
}
Go the facebook folder which you have imported in your project. Copy the gradle.properties file and paste in into your facebook module.It will remove the errors.
For those who ran into same problems while adding libraries and still can't get it work. The following local include of the .aar file worked for me:
Just download the .aar file from the maven repo manually.
In Android Studio go to File -> new Module -> import .JAR or
.AAR package and select your downloaded .aar file.
Android Studio does the rest (in the build.gradle) for you. Maybe clean and rebuild your project.
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 8
targetSdkVersion 4
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
}

Categories

Resources