Android resource linking failed - AAPT: error: resource android:attr/dialogCornerRadius not found - gradle

I am receiving errors when trying to bundle an android release for a react-native project. This project should be converted to AndroidX as a note.
Error Messages
When trying to build a release build for Android I receive the following errors:
* What went wrong:
Execution failed for task ':react-native-vector-icons:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> 1 exception was raised by workers:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/.../.gradle/caches/transforms-2/files-2.1/5c74eb36d229b35abeeb690f5d3b91a3/appcompat-1.0.0/res/values-v28/values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
/Users/.../.gradle/caches/transforms-2/files-2.1/5c74eb36d229b35abeeb690f5d3b91a3/appcompat-1.0.0/res/values-v28/values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
/Users/.../.gradle/caches/transforms-2/files-2.1/f54ae08833e39bf2b75fd420ffea65b9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/fontVariationSettings not found.
/Users/.../.gradle/caches/transforms-2/files-2.1/f54ae08833e39bf2b75fd420ffea65b9/core-1.0.0/res/values/values.xml:57:5-88:25: AAPT: error: resource android:attr/ttcIndex not found.
Root Build.gradle file
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0-alpha1"
reactNativeVersion = "0.59.9"
}
repositories {
jcenter()
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath('com.android.tools.build:gradle:3.6.3')
classpath 'com.google.gms:google-services:4.2.0'
// Add the Crashlytics Gradle plugin.
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.1'
}
}
allprojects {
repositories {
google()
mavenLocal()
maven {
url 'https://maven.google.com/'
name 'Google'
}
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// React native video - exoplayer missing from google repos, temp fix
maven {
url "https://google.bintray.com/exoplayer/"
}
jcenter()
}
}
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0-alpha1"
reactNativeVersion = "0.59.9"
}
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion compileSdkVersion
buildToolsVersion "$buildToolsVersion"
}
}
}
}
App build.gradle file
dependencies
dependencies {
implementation project(':react-native-safe-area-context')
implementation 'com.android.support:support-annotations:28.0.3'
implementation "androidx.annotation:annotation:1.1.0"
implementation project(':react-native-video')
implementation(project(":react-native-google-signin"))
implementation project(':react-native-splash-screen')
implementation project(':react-native-iap')
implementation project(':react-native-version-check')
implementation project(':react-native-vector-icons')
implementation project(':react-native-linear-gradient')
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation project(':react-native-fbsdk')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-vector-icons')
implementation project(':react-native-fbsdk')
implementation project(':react-native-vector-icons')
// react-native-google-signin
// react-native-fbsdk
implementation 'com.facebook.android:facebook-android-sdk:4.33.0'
implementation project(':react-native-fbsdk')
// RNFirebase required dependencies
implementation "com.google.firebase:firebase-core:16.0.9"
implementation "com.google.android.gms:play-services-base:17.0.0"
// RNFirebase optional dependencies
implementation "com.google.firebase:firebase-auth:17.0.0"
implementation "com.google.firebase:firebase-database:16.0.5"
implementation "com.google.firebase:firebase-firestore:17.1.4"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation ("com.facebook.react:react-native:0.59.9") {force = true} // From node_modules
implementation 'com.google.firebase:firebase-crashlytics:17.0.1'
}
Research
I have seen some other issues of this being reported such as:
React-native(android) AAPT: error: resource android:attr/dialogCornerRadius not found
https://fincoapps.com/error-resource-androidattr-dialogcornerradius-not-found/.
However, these look to be setup as you'd expect. One issue suggests the subprojects edit that exists in the root build.gradle file, but the same error messages always occur.
Edit
gradle-wrapper.properties
#Thu May 07 14:26:41 BST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
android.enableJetifier=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
android.useAndroidX=true
React-native info
npmPackages:
react: ^16.7.0 => 16.13.1
react-native: 0.59.9 => 0.59.9
npmGlobalPackages:
react-native-cli: 2.0.1

Solution 1:
Check what all react native projects are supporting androidX now.
gradlew app:dependencies
Search for androidX in the output. Get all the libraries having androidx.
Make a change in build.gradle inside android/app
configurations.all {
resolutionStrategy {
force 'com.google.android.gms:play-services-gcm:16.1.0'
force 'com.google.android.gms:play-services-basement:16.2.0'
force 'com.google.android.gms:play-services-auth:16.0.1'
force 'com.google.firebase:firebase-messaging:18.0.0'
force 'com.google.firebase:firebase-common:17.0.0'
force 'com.google.firebase:firebase-iid:18.0.0'
force 'com.google.android.gms:play-services-stats:16.0.1'
force 'com.google.android.gms:play-services-base:16.0.1'
}
}
These were the libraries that caused problem in my react native project.
Google maintains all the releases here https://developers.google.com/android/guides/releases#may_07_2019 . You can choose any other version also. This solution solved issue in my case. Let me know if this helps.
Solution 2
rm -rf android/.gradle
rm -rf .gradle
rm -rf ~/.gradle
./gradlew clean

Related

Unable to archive Kotlin Native with Cocoapods in XCode

I try to archive in XCode 12 a project referencing a Kotlin Native framework with cocoapods plugin, but it fails with message like this (using iPhone SE to build archive)
Ignoring file *MyFramework*, building for iOS-armv7 but attempting to link with file built for iOS-arm64
Undefined symbol: _OBJC_CLASS_$_... (for armv7)
I reference my framework in Podfile of the project as a local pod (using :path and :modular_headers => true)
As I understand I have to build a fat framework to include both armv7 and arm64 but how do I manage this using Kotlin cocoapods plugin?
Here are some links with recommendations, but I was unable to put it together in my case
https://github.com/ilmat192/kotlin-native-gradle-samples/blob/master/fat-framework/build.gradle.kts
https://github.com/JetBrains/kotlin-native/issues/3140
https://medium.com/#yuyaHorita/universal-frameworks-xcframework-with-kotlinnative-999d830e206e
https://github.com/JetBrains/kotlin-native/issues/2574
https://github.com/ilmat192/kotlin-native-gradle-samples/blob/master/fat-framework/build.gradle.kts
Project's build.gradle
buildscript {
ext.kotlinVersion = '1.4.20-M2'
// use 1.3.7 to avoid iOS build error
// "Deserializer for declaration public kotlinx.coroutines/SingleThreadDispatcher|null[0] is not found"
ext.coroutinesVersion = '1.3.7'
ext.ktorVersion = '1.4.1'
ext.napierVersion = '1.4.0'
repositories {
google()
jcenter()
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
repositories {
google()
jcenter()
}
Molule's build.gradle
plugins {
id 'org.jetbrains.kotlin.multiplatform' version "$kotlinVersion"
id "org.jetbrains.kotlin.native.cocoapods" version "$kotlinVersion"
id "org.jetbrains.kotlin.plugin.serialization" version "$kotlinVersion"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://dl.bintray.com/aakira/maven" }
maven { url "https://dl.bintray.com/kotlin/kotlin-eap" }
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId 'org.jetbrains.kotlin.mpp_app_android'
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName '1.0'
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
}
kotlin {
android("android")
targets {
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
? presets.iosArm64 : presets.iosX64
// https://kotlinlang.org/docs/reference/mpp-dsl-reference.html#native-targets
fromPreset(iOSTarget, 'ios') {
binaries {
}
}
}
// CocoaPods requires the podspec to have a version.
version = "1.0"
cocoapods {
// Configure fields required by CocoaPods.
def projectName = project.getRootProject().getName()
summary = projectName
homepage = "https://ya.ru"
ios.deploymentTarget = "9.0"
frameworkName = projectName
pod("NVHTarGzip")
}
sourceSets {
commonMain {
dependencies {
implementation kotlin('stdlib')
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:0.9.1")
// Coroutines components
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
// workaround https://youtrack.jetbrains.com/issue/KT-41378
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9-native-mt-2")
// Ktor components
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-network:$ktorVersion")
// workaround https://github.com/AAkira/Napier/issues/48
implementation "com.github.aakira:napier:1.4.1-alpha1"
}
}
commonTest {
dependencies {
implementation kotlin('test-common')
implementation kotlin('test-annotations-common')
}
}
androidMain {
dependencies {
// Ktor components
implementation("io.ktor:ktor-client-android:$ktorVersion")
}
}
androidTest {
dependencies {
implementation kotlin('test')
implementation kotlin('test-junit')
}
}
iosMain {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.9.1")
// Ktor components
implementation("io.ktor:ktor-client-ios:$ktorVersion")
}
}
iosTest {
}
}
}
Solution
Actually not a true solution - based on accepted answer I just dropped armv7 support adding it to Excluded Architectures
building for iOS-armv7 but attempting to link with file built for iOS-arm64
Looks like you're trying to archive for armv7, which (I think) is 32 bit ios, or maybe watch, etc. Most apps need just arm64, and your Xcode framework will only be arm64 according to this:
final def iOSTarget = System.getenv('SDK_NAME')?.startsWith("iphoneos") \
? presets.iosArm64 : presets.iosX64
If you only need arm64, and if it's just an iOS app, that seems likely, you can disable armv7 architecture in your build. Alternatively, you might try the combined ios() target.
We have a functional example here: https://github.com/touchlab/KaMPKit
It is using a fork of the cocoapods plugin, but besides isStatic, it's basically the same plugin.

React Native Project Android Gradle Fail (React-Native-Reanimated Fail)

I was in the middle of coding an app using VS Code and react-native and after trying to install react-native-material-ripple I ran into the following error trying to build my app:
///////////////////////////////////////////////////////////////////////////////////////////////
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\D'errah\Documents\Code\React\dowProjectMatcher\node_modules\react-native-reanimated\android\build.gradle' line: 89
What went wrong:
A problem occurred configuring project ':react-native-reanimated'.
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
//////////////////////////////////////////////////////////////////////////////////////////////
The app was working perfectly before then. I went to the file in question and looked at the line the error mentioned:
mentioned line:
classpath += files(android.bootClasspath)
full file:
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
buildscript {
if (project == rootProject) {
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// Android JSC is installed from npm
url "$rootDir/../node_modules/jsc-android/dist"
}
google()
jcenter()
}
dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation "androidx.transition:transition:1.1.0"
}
def configureReactNativePom(def pom) {
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
pom.project {
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.swmansion.reanimated"
description packageJson.description
url packageJson.repository.baseUrl
licenses {
license {
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
}
}
developers {
developer {
id packageJson.author.username
name packageJson.author.name
}
}
}
}
afterEvaluate { project ->
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
classpath += files(project.getConfigurations().getByName('compile').asList())
include '**/*.java'
}
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
classifier = 'javadoc'
from androidJavadoc.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
include '**/*.java'
}
android.libraryVariants.all { variant ->
def compileTask
if (variant.hasProperty('javaCompileProvider')){
compileTask = variant.javaCompileProvider.get()
}else{
compileTask = variant.javaCompile
}
def name = variant.name.capitalize()
task "jar${name}"(type: Jar, dependsOn: compileTask) {
from compileTask.destinationDir
}
}
artifacts {
archives androidSourcesJar
archives androidJavadocJar
}
task installArchives(type: Upload) {
configuration = configurations.archives
repositories.mavenDeployer {
// Deploy to react-native-event-bridge/maven, ready to publish to npm
repository url: "file://${projectDir}/../android/maven"
configureReactNativePom pom
}
}
}
The problem is, I'm pretty sure that how that line was already even while the app was working. So I've spent the last few hours googling and haven't been able to figure out what cause the issue/how to fix it.
Any help would be GREATLY appreciated!
Things to note:
-using VS Code
-Was working before installing react-native-material-ripple (tried uninstalling, test, reinstalling, test)
Same error occurred for me also, please go through this documentation for proper installation setup for react-native-reanimate.
Install latest
yarn add react-native-reanimated#next
or
npm i react-native-reanimated#next
now go to android dir and gradlew clean, for more details go through below link
https://docs.swmansion.com/react-native-reanimated/docs/installation

Gradle not finding org.apache.commons:commons-imaging

Gradle cannot resolve org.apache.commons:commons-imaging, yet it is available in all 3 of the provided repositories:
http://jump-pilot.sourceforge.net/repository
https://repo.adobe.com/nexus/content/repositories/public/
https://repository.apache.org/content/repositories/snapshots/
This part of the log is interesting, Gradle looks only in jcenter and the local filesystem:
https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
Console log (requesting org.apache.commons:commons-imaging:1.0-SNAPSHOT):
$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find org.apache.commons:commons-imaging:1.0-SNAPSHOT.
Searched in the following locations:
https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
https://jcenter.bintray.com/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
file:/Users/user/Library/Android/sdk/extras/android/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/maven-metadata.xml
file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.pom
file:/Users/user/Library/Android/sdk/extras/google/m2repository/org/apache/commons/commons-imaging/1.0-SNAPSHOT/commons-imaging-1.0-SNAPSHOT.jar
Required by:
ReactNativeProject:app:unspecified > ReactNativeProject:react-native-image-store-ext:unspecified
Console log (requesting org.apache.commons:commons-imaging:+):
$ react-native run-android
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find any matches for org.apache.commons:commons-imaging:+ as no versions of org.apache.commons:commons-imaging are available.
Required by:
ReactNativeProject:app:unspecified > ReactNativeProject:react-native-image-store-ext:unspecified
build.gradle:
buildscript {
repositories { jcenter() }
dependencies { classpath 'com.android.tools.build:gradle:2.1.0' }
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
lintOptions { abortOnError false }
}
repositories {
mavenCentral()
maven { url "http://jump-pilot.sourceforge.net/repository" }
maven { url "https://repo.adobe.com/nexus/content/repositories/public/" }
maven { url "https://repository.apache.org/content/repositories/snapshots/" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile "com.facebook.react:react-native:+"
compile 'org.apache.commons:commons-imaging:+'
}
There are 2 build.gradle file in android project: the one inside main project folder and the one inside app folder. The repository should be defined under allprojects block inside project folder. Here, example of my build.gradle which successful build apache commons imaging.
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 {
jcenter()
maven { url "http://jump-pilot.sourceforge.net/repository" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Apparently, there is no oficial version for apache commons imaging yet.
The latest unoficial version I have found, is on this repo
maven { url "http://wcm.io/maven/repositories/apache-intermediate-release/" }
Add this line on the build.gradle as opris said.
Then, in your gradle app/module file, add this
dependencies {
...
implementation 'org.apache.commons:commons-imaging:1.0-R1725432'
...
}
I haven't tested it yet, so I will have to choose between this one and the oficial version of sanselan,
compile 'org.apache.sanselan:sanselan:0.97-incubator'
which has no more support

Android Studio V1.0.2,Error:(2, 0) Gradle DSL method not found: 'compile()'?

Android Studio 1.0.2 with gradle 1.0.0 on Mac
when I start a new project,gradle project sync failed with errors:
Error:(2, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'My Application' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
build.gradle under project
// 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.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle under app
dependencies {
compile 'com.android.support:appcompat-v7:21.+'
}
apply plugin: 'com.android.application' android {
compileSdkVersion 21 buildToolsVersion "21.1.1" defaultConfig {
applicationId "com.macernow.djstava.myapplication" minSdkVersion 14 targetSdkVersion 21 versionCode 1 versionName "1.0"
} buildTypes {
release {
minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
} dependencies {
compile 'com.android.support:appcompat-v7:21.+' compile fileTree(dir: 'libs', include: ['*.jar'])
}
And I also try online/offline gradle settings,the error remains.Please help me,thanks.
Uninstall Android Studio cleanly by
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*
And then reinstall it,everything is OK.

Android Studio: Library not recognizing the Android API

I am trying to add this library to my project. I put the files from GitHub in my libraries directory under my project's default module folder.
When I first added the library, it wasn't recognized in my project until I changed the the folder structure from httpzoid/src/ to httpzoid/src/main/java.
At this point I am able to import classes from the library. The only problem is, Android components such as android.content.Context aren't recognized by the library, so it basically doesn't work.
The project does not have a Ant or Gradle build file so need to create one.
First you will need to delete the local.properties since it references the developers local sdk directory. Then create a file named build.gradle in the projects directory with the following content.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
apply plugin: 'android-library'
android {
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
}
compileSdkVersion 19
buildToolsVersion "19.0.3"
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
}
dependencies {
compile 'com.google.code.gson:gson:2.2.4'
}
Then in command line go to the projects root directory and run "gradle build". This will generate the file "Httpzoid.aar" in the projects build/libs directory. Copy this file into your main project's libs folder.
You'll now be able to add it as a dependency by modifying your project's build.gradle file and adding the following:
dependencies {
repositories {
flatDir {
dirs 'libs'
}
}
compile(name:'Httpzoid', ext:'aar')
}
As an aside, have you considered using Retrofit or Ion as an alternative REST client? These two excellent libraries have similar callback mechanisms and both are actively updated (Last update for HttpZoid was July 22, 2013). Also they are both on Maven Central.

Resources