I suddenly started getting this error when trying to build. This was all working a few weeks ago with no changes that I know of. The issue seems to be related to react-native-fbsdk, but looking through its build.gradle it does not list support.appcompat-v7.25.x. Any advice?
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-fbsdk'.
> Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugCompile'.
> Could not find com.android.support:appcompat-v7:25.3.1.
Searched in the following locations:
file:/Users/a/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom
file:/Users/a/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar
https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar
build.gradle
apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "___"
minSdkVersion 16
targetSdkVersion 23
versionCode 22
versionName "1.5.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
manifestPlaceholders = [manifestApplicationId: "___",
onesignal_app_id: "___",
onesignal_google_project_number: "___"]
multiDexEnabled true
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-device-info')
compile project(':react-native-code-push')
compile project(':react-native-image-crop-picker')
compile project(':react-native-image-picker')
compile project(':react-native-fs')
compile project(':react-native-vector-icons')
compile project(':react-native-material-kit')
compile project(':react-native-config')
compile project(':react-native-onesignal')
compile project(':react-native-push-notification')
compile project(':react-native-android-permissions')
compile project(':react-native-android-keyboard-adjust')
compile project(':react-native-fbsdk')
compile (project(':react-native-fbads')) {
exclude group: 'com.google.android.gms'
}
compile 'com.facebook.android:audience-network-sdk:4.18.+'
compile 'com.google.ads.mediation:facebook:4.18.+'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile project(':react-native-billing')
compile project(':react-native-blur')
compile project(':instabug-reactnative')
compile project(':mobile-center-analytics')
compile project(':mobile-center-crashes')
compile (project(':react-native-appodeal')) {
exclude group: 'com.facebook.ads'
exclude (group: 'javax.inject', module: 'javax.inject')
}
compile project(':cheetah')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.facebook.fresco:animated-gif:0.12.0"
compile "com.android.support:multidex:1.0.1"
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
I've had the same problem (appcompat-v7:25.3.1), on an android project, but not using react.
I first tried to clean the gradle cache (~/.gradle/caches), like explained here, but it didn't help.
Then I looked at the SDK Manager.
Android Support libraries are normally installed via sdkmanager.
The libraries are then stored in a local maven repository : <SDK_HOME>/sdk/extras/android/m2repository/.
For example, for appcompat-v7 the list of versions installed is in <SDK_HOME>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml.
So, for the Android Support Repository (revision: 47.0.0), the last version was normally 25.3.1.
To fix my problem, I had to uninstall the Android Support Repository via the SDK Manager, then reinstall it.
I also found another way to fetch support libraries : remotely.
After reading here (https://developer.android.com/topic/libraries/support-library/setup.html#add-library) and modifying <PROJECT_ROOT>/build.gradle like this :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Then I tried to use a newer version of appcompat-v7:25.4.0 that was not in my local maven repository, and it worked !
The list of this Google Maven repository's versions of this library can be seen there : https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/maven-metadata.xml.
Follow the steps,
Add google maven in project gradle (Project: build.gradle),
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Remove existing gradle cache with below command
rm -fr ~/.gradle/caches/
Have a clean build and run
My case was that this is react-native-fbsdk build.gradle (https://github.com/facebook/react-native-fbsdk/blob/master/android/build.gradle):
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
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 'com.android.support:appcompat-v7:23.1.0'
compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
compile('com.facebook.android:facebook-android-sdk:4.+')
}
I am using React Native 0.37, so this is the line that broke for me:
compile('com.facebook.android:facebook-android-sdk:4.+')
Had to change to this for compatibility:
compile('com.facebook.android:facebook-android-sdk:4.18.+')
For this, try one of the following option:
1. Update your SDK manager > Go to build menu > clean project > then build project
or
2. Right click on project folder > open module setting > libraries > add com.android.support:appcompat-v7:25.3.1 > sync the project
3. Click on file menu > open project structure > and file the libraries
To solve this problem:
Open package.json and edit the react version to:
"react": "16.0.0-alpha.3",
"react-native": "0.43.1",
Delete node_modules directory
And re-install npm with the command npm install
In Addition: If you get a app:compileDebugJava ERROR, run react-native upgrade
(Got the solution from this github page and it worked for me)
Since gradle doesn't support declaring repositories on a per-artifact basis yet.
I modified my build.gradle (not app/build.gradle) to force all dependency to react-native to specific version:
allprojects {
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
def file = new File("$rootDir/../node_modules/react-native/package.json")
def version = new groovy.json.JsonSlurper().parseText(file.text).version
details.useVersion version
}
}
}
}
}
This seems to be an issue with react-native itself.
There is no official fix for this (yet), however some people have reported upgrading to have solved their problem. You can check more details here
Update 1:
Hi #roachman, this is the exact error I got which pointed me to search for above. There is another ticket logged #14225 for same(cannot post link for some reason). I was just able to resolve it by including exact version of react-native version in build.gradle dependencies line compile "com.facebook.react:react-native:0.xx.y" instead of compile 'com.facebook.react:react-native:+' You might want to try that for all projects that use that setting or a more elegant settings suggested in above in issue #14223 by user david50407
Update 2
This is officially fixed now have a look https://github.com/facebook/react-native/issues/14225#issuecomment-305073392 (had to remove earlier link for issue 14223 as I cannot post more than 2 links)
If you upgraded react-native-fbsdk from 0.5 to 0.6 versions and have this issue then open your android project (pathToYourApp/android) in Android Studio and it automatically offers you to update dependencies. Now It should work fine!
Related
I'm running react-native app via Android Studio and I keep running into a build error with the android support dependencies. I have the necessary SDK platform and tools installed via Android Studio and yet I still run into this error.
Could not find com.android.support:support-v7:26.0.2.
At first I was using 27.0.3, but then I noticed all of my libraries were defaulting to 26.0.2 as stated by the following warning message during the build -
The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (26.0.2) for Android Gradle Plugin 3.0.1.
Android SDK Build Tools 26.0.2 will be used.
I've consulted a variety of StackOverflow solutions and the build fails every time. Any thoughts on what I could be doing wrong?
app/build.gradle
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.jast"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-fetch-blob')
compile project(':react-native-aws')
compile project(':react-native-image-picker')
compile project(':react-native-mail')
compile project(':react-native-rate')
compile project(':appcenter-crashes')
compile project(':appcenter-analytics')
compile project(':appcenter')
compile project(':react-native-fcm')
compile(project(':react-native-firebase')) {
transitive = false
}
compile project(':react-native-maps')
compile project(':react-native-linear-gradient')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:26.0.2"
compile "com.android.support:support-v7:26.0.2"
compile "com.facebook.react:react-native:+" // From node_modules
}
Check the following conditions in your code.
Check to see if your there is google() in your project level build.gradle. If not make sure that where jcenter() occurs place google() above jcenter().
Check if gradle-wrapper.properties has the corresponding gradle version with regards to appcompat version and sdkversion in defaultConfig in app level build.gradle
update project level gradle dependencies to the latest version:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
}
I developed an app that uses a swagger-generated Java client. The client is in a project called "api", while the app is in a project called "app".
When I build the app via Build/Make Project everything works fine. Also, when I try to run the app on an emulated or physical device Run/Run 'app'. Running with debugger works as well. Even when I build the project via Buid/Generate Signed Bundle/APK and choose the debug option, it works.
Now. The build fails when I try to create a signed release build. The following messages show:
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: [...]\app\build\intermediates\transforms\dexBuilder\release\54, [...]\app\build\intermediates\transforms\externalLibsDexMerger\release\0, [...]\app\build\intermediates\transforms\dexBuilder\release\52.jar, [...]\app\build\intermediates\transforms\dexBuilder\release\53.jar
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: [...]\app\build\intermediates\transforms\dexBuilder\release\54, [...]\app\build\intermediates\transforms\externalLibsDexMerger\release\0, [...]\app\build\intermediates\transforms\dexBuilder\release\52.jar, [...]\app\build\intermediates\transforms\dexBuilder\release\53.jar
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: io.swagger.client.ApiCallback
I am pretty new to developing with Android Studio and Gradle. I tried some solutions on Stack Overflow that already suggested to add some libraries but so far none of them worked with my problem.
To me, its especially suspicious that the last error message points to io.swagger.client.ApiCallback.
Could it have anything to do with the fact that both settings.gradle for "api" and "app" have the same content? Both look like this:
rootProject.name = "swagger-java-client". This is the only line in the file, but as far as I know, the settings.gradle for "app" already hat that content. I cant remember changing it so its odd to me that it shows "swagger-java-client". Is that normal?
Update 1
ProGuard has been mentioned in the comments to might be a problem. This is the only occurrence I could find, referencing it. In my build.gradle for the "app"-project, there is this part:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
However, removing it did not change anything.
Update 2
When searching for "io.swagger" AS only finds this:
When searhing for "io.swagger.client.ApiCallback" AS only finds this:
Update 3
As suggested, I tried adding
android {
defaultConfig {
multiDexEnabled true
}
}
and adding android.enableD8 = false but that didn't help either.
Here are my build.gradle-Files (the first ones that caused the problems, without the suggested corrections I've tried so far.)
build.gradle (Module: api) (generated by Swagger):
apply plugin: 'idea'
apply plugin: 'eclipse'
group = 'io.swagger'
version = '1.0.0'
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
}
repositories {
jcenter()
}
if(hasProperty('target') && target == 'android') {
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 25
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${project.name}-${variant.baseName}-${version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
dependencies {
provided 'javax.annotation:jsr250-api:1.0'
}
}
afterEvaluate {
android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
} else {
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
install {
repositories.mavenInstaller {
pom.artifactId = 'swagger-java-client'
}
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
dependencies {
compile 'io.swagger:swagger-annotations:1.5.21'
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
compile 'com.google.code.gson:gson:2.8.2'
compile 'org.threeten:threetenbp:1.3.5'
testCompile 'junit:junit:4.12'
}
build.gradle (Module: app):
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 28
defaultConfig {
applicationId "projectName"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "0.1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation fileTree(dir: '../api/build/libs', include: ['*.jar'])
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.squareup.okhttp:okhttp:2.7.5'
api project(path: ':api')
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.8'
implementation 'org.jetbrains:annotations-java5:15.0'
}
Here are some workaround :
Can you please make sure you have multiDexEnabled set to true as shown below in your gradle settings:
android {
defaultConfig {
multiDexEnabled true
}
}
Try android.enableD8 = false in grade.properties
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: io.swagger.client.ApiCallback
Means there are multiple dependencies contain this class, maybe different versions, so you need to exclude them.
Press shift twice, search io.swagger, then record the found jar files.
If these jar files are simply duplicated, keep 1 in build.gradle.
If these jar files are modules of other dependency, enter gradlew -q app:dependencies in the terminal, find the root dependency names.
In build.gradle, choose 1 dependency to keep, for others add exclude command.
For example change
implementation 'xxx:xxx'
to
implementation ('xxx:xxx') { exclude module 'module-name-to-be-excluded' }
UPDATE
Some options to try:
Change build variants of both modules to release, then Build\Build APK
If success, copy the text from Gradle Console.
Next Build\Generate Signed APK...
Compare the text in Gradle Console with the above one to check the difference.
I've found the answer to my question:
What I did was to create the swagger client, move the created folder into my project, adjust the settings.gradle file and the build.gradle file accordingly.
What went wrong
The way I configured things, gradle would build the ´api´ project and then the app project.
For some reason, when I configured things as release, the app project referenced the code of the api project, as well as the resulting .jar file. Thats where the Program type already present came from.
How I fixed it
Exclude the api project from the app project
Build api seperately
Take the resulting .jarfile and put it in a folder inside your app folder called libs
Put this line in your gradle dependencies for your build.gradle (Module: app): implementation fileTree(dir: 'libs', include: ['*.jar'])
This included the finished .jarfile in the appproject and now I can build release. This should be done regardless, because the swagger client shouldnt be edited anyway, as it is generated code. So even just to not always build that part of the project, this should be done.
However, I still dont fully understand why there is this difference between the releaseand the debugbuild. Would be glad for any insight to that.
EDIT: ADDITIONAL INFORMATION
I just found out: if, for some reason, I would have wanted to keep the Module: api in my project I could have done so by removing the two dependencies in my Module: appthat start with implementation fileTree.
The api-project is already included by the dependency api project(path: ':api'). The filetree-lines were the ones causing the problem here, since they were redundant.
However, still no idea why there is a difference between debug and release
I have a react-native app and I'm trying to import the FB Android SDK and FB Audience Network SDK with the mediation adapter.
When I add these dependencies in my app/build.gradle, I get the following errors during build.
compile 'com.facebook.android:facebook-android-sdk:4.22.1'
compile 'com.facebook.android:audience-network-sdk:4.26.1'
compile 'com.google.ads.mediation:facebook:4.26.1.0'
Errors:
C:\ig3\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
C:\ig3\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
C:\ig3\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
C:\ig3\android\app\build\intermediates\res\merged\debug\values-v24\values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
The only way I could get my project to compile was to do this in android/build.gradle:
allprojects {
....
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
details.useVersion "0.49.5" // Your real React Native version here
}
}
force 'com.facebook.android:facebook-android-sdk:4.22.1' <---Add this line
force 'com.facebook.android:audience-network-sdk:4.26.1' <---Add this line
}
}
}
And comment out these two lines in android/app/build.gradle:
//compile 'com.facebook.android:facebook-android-sdk:4.22.1'
//compile 'com.facebook.android:audience-network-sdk:4.26.1'
compile 'com.google.ads.mediation:facebook:4.26.1.0'
If I try any other version of FB Android SDK in android/build.gradle I get the same errors mentioned earlier. After some research, I tried changing the com.android.support:appcompat version but it will always give the same error as above if I do not use 23.
Is this an acceptable way to include these dependencies? It feels like a hack, I don't know why I could not just include the sdks in android/app/build.gradle, and I don't want to be stuck on FB android sdk version 4.22.1 forever.
Also, after testing it does not seem like ad mediation is working from Admob for Facebook Audience Network but I am unsure if it is due to the way I import the sdk like above or an unrelated issue.
If anybody can show me how to correctly include the sdks I would appreciate it. Thanks!
EDIT:
Full android/build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.google.com' }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
details.useVersion "0.49.5" // Your real React Native version here
}
}
force 'com.facebook.android:facebook-android-sdk:4.22.1'
force 'com.facebook.android:audience-network-sdk:4.26.1'
}
}
}
And full android/app/build.gradle:
android {
compileSdkVersion 23
buildToolsVersion '25.0.2'
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 22
versionCode 50
versionName "1.11.11"
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
dexOptions {
jumboMode = true
javaMaxHeapSize "4g"
}
signingConfigs {
release {
....
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a": 1, "x86": 2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.android.support:appcompat-v7:23+'
compile project(':react-native-fetch-blob')
compile 'com.android.support:multidex:1.0.1'
compile project(':react-native-billing')
compile project(':bugsnag-react-native')
compile project(':react-native-admob')
compile fileTree(dir: "libs", include: ["*.jar"])
compile project(':react-native-fbsdk')
compile project(':react-native-code-push')
compile project(':react-native-device-info')
compile project(':react-native-config')
compile project(':react-native-fast-image')
compile project(':react-native-camera')
compile project(':react-native-google-analytics-bridge')
compile project(':react-native-vector-icons')
compile(project(":react-native-google-signin")) {
exclude group: "com.google.android.gms" // very important
}
compile 'com.google.android.gms:play-services-auth:11.6.0'
compile 'com.google.firebase:firebase-appindexing:11.6.0'
compile 'com.facebook.android:facebook-android-sdk:4.22.1'
compile 'com.facebook.android:audience-network-sdk:4.26.1'
compile 'com.google.ads.mediation:facebook:4.26.1.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
My solution was to update all these:
gradle to 3.01
gradle wrapper to 4.1
compilesdkversion to 26
buildtoolsversion to 26.02
com.android.support:appcompat-v7 to 26+
com.facebook.android:facebook-android-sdk:4.28.0
and my app builds successfully
Here is the content of my build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven {
credentials {
username artifactoryUserName
password artifactoryPassword
}
url 'http://test:8081/artifactory/libs-release-local'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
allprojects {
repositories {
maven {
credentials {
username artifactoryUserName
password artifactoryPassword
}
url 'http://test:8081/artifactory/libs-release-local'
}
mavenCentral()
maven { url 'http://repo1.maven.org/maven2' }
jcenter()
} }
Here is the content of app\build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
lintOptions {
abortOnError false
}
defaultConfig {
applicationId "test.com"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
signingConfigs {
aseeConfig {
storeFile file("test.keystore")
storePassword "test123"
keyAlias "AndroidKey"
keyPassword "test123"
}
}
buildTypes {
release {
signingConfig signingConfigs.aseeConfig
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
prod.initWith(buildTypes.release)
prod {
signingConfig signingConfigs.aseeConfig
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
} }
dependencies {
//compile 'com.google.android:support-v4:r13'
compile 'com.google.android:google-play-services:4.1.32'
compile 'com.devsmart.android:devsmart-lib:1.0.0'
compile 'com.jeremyfeinstein.slidingmenu.lib:sliding-menu:1.0.0'
compile 'com.viewpagerindicator:viewpager-indicator:2.4.1'
///compile 'com.google.android.gms:google-play-services_lib:4.1.32'
compile 'com.emilsjolander:sticky-list-headers:1.0.0'
//compile 'com.actionbarsherlock:actionbar-sherlock:4.2.0'
compile 'com.mobeta.android.dslv:drag-sort-list-view:0.6.1'
compile 'com.threegvision.products:inigma_sdk_pro:3.24'
compile 'org.afree:a-free-chart:1.0.0'
compile 'org.afree:a-free-graphics:1.0.0'
compile 'net.simonvt:datepicker:1.0'
//compile 'eu.inmite:android-styled-dialogs:1.1'
compile 'com.nineoldandroids:nine-old-androids:2.4.1'
compile 'com.shinobicontrols.charts:shinobicharts:1.5.0-5'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.daimajia.slider:library:1.1.5#aar'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.journeyapps:zxing-android-embedded:3.0.1#aar'
compile 'com.google.zxing:core:3.2.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/actionbarsherlock-4.2.0.jar')
compile files('libs/android-styled-dialogs-1.1.1-sources.jar')
compile files('libs/android-support-4.0.jar')
}
I can't build my project . I am getting this error:
I faced this kind of issue once but I don't remember exactly how to fix it.
As I rememeber, I follow this link
It's seem because there are many module dependent on difference support-v4 lib. So add multiDexEnabled true may works.
Also try to set all modules' dependency to a same version of support-v4. You can look at these link to known how to exclude compile v4 link1 link2 link3
If it still doesn't work, try to clean project, restart Studio, even restart your computer(I don't know why but this worked for me once)
Hope this helps.
in your build.gradle file set your compileSdkVersion 20.0.0 and buildToolsVersion "21.0.0"
Generally, it is because of resource conflicts within your modules.For sample, there are two ic_launcher.png in your app.(one from module and one from your app)
I searched to check resource conflicts but I didn't find official solution.
I only solved by this ways, remove each module and test it is being conflict or not. That's the simplest way to solve. I hope this will help you.
Here below are another suggestion....
I found also this way, one person(I didn't remember name) use safe delete to check conflict.
And some Q&A said, to add multiDexEnabled:true. That config is to increase dex file size. You can also use multidex support library .
The Dalvik Executable specification limits the total number of methods that can be referenced within a single DEX file to 65,536, including Android framework methods, library methods, and methods in your own code. Getting past this limit requires that you configure your app build process to generate more than one DEX file, known as a multidex configuration.
Here is the link for multiDex:
https://developer.android.com/tools/building/multidex.html
But documentation said you should be careful to use that.
I am trying to add Dexguard to Android Studio. I have followed the guidelines so my build.gradle is the following:
buildscript {
repositories {
mavenCentral()
flatDir { dirs '/Users/XXXX/Desktop/DexGuard5.3.00/lib' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.4'
classpath ':dexguard:'
}
}
apply plugin: 'dexguard'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
proguardFile plugin.getDefaultDexGuardFile('dexguard-debug.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
release {
proguardFile plugin.getDefaultDexGuardFile('dexguard-release.pro')
proguardFile 'dexguard-project.txt'
proguardFile 'proguard-project.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
Then I try to build the project and I get the following error:
Error:A problem occurred configuring project ':XXXX'.
No such property: baseName for class: com.android.build.gradle.internal.variant.ApplicationVariantData
Has anyone experienced such problem again?
Thank you in advance!
The Gradle plugin for DexGuard 5.3.00 is compatible with the Android plugin 0.5.1, so you should adapt the class path at the top of the file.
You probably want to install the latest version of the Gradle plugin though. At this time of writing, the Gradle plugin for DexGuard 5.5 is compatible with the Android plugin 0.9.0.
As a reference, you can always find working sample projects with build files in DexGuard's samples directory.
First you can try to add nexusUsername=123 nexusPassword=123 in the "project/maven_push.gradle"
Then if it report "Error:Could not find property 'allJava' on source set main."
you can try this:
task androidJavadocs(type: Javadoc) {
// comment it if you find
//source = android.sourceSets.main.allJava
}
task androidJavadocsJar(type: Jar) {
classifier = 'javadoc'
//basename = artifact_id
// comment it if you find
//from android.sourceSets.main.allSource
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
//basename = artifact_id
////comment it if you find
//from android.sourceSets.main.allSource
}
Last it‘s not my answer ,I found it in an small blog~~~Thanks to the authoer ,it sloved my problems~
Good luck to you ~