i'm trying react native integrate to existing android project but throwed below exception when build project in android studio.
Caused by: java.lang.Exception: React Native CLI failed to determine Android project configuration. This is likely due to misconfiguration. Config output:
[root:/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/android, reactNativePath:/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/node_modules/react-native, dependencies:[:], commands:[], assets:[], platforms:[:], haste:[providesModuleNodeModules:[], platforms:[]], project:[:]]
at ReactNativeModules.getReactNativeConfig(/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/node_modules/#react-native-community/cli-platform-android/native_modules.gradle:212)
at ReactNativeModules$getReactNativeConfig.callCurrent(Unknown Source)
at ReactNativeModules.(/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/node_modules/#react-native-community/cli-platform-android/native_modules.gradle:84)
at native_modules_8dnp0y65ugw2tp4vo89t6lw0x.run(/Users/muratoner/Desktop/backup/Sabanci.Projects/Mobile/hrweb-react-native/node_modules/#react-native-community/cli-platform-android/native_modules.gradle:244)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 148 more
React native package.json
{
"name": "MyApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "yarn react-native start"
},
"dependencies": {
"#react-native-community/cli-platform-android": "^3.0.3",
"react": "^16.9.0",
"react-native": "^0.61.5"
}
}
android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
// Add Maven repo
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
//classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url 'https://jitpack.io' }
maven {
// All of React Native (JS, 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")
}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android/settings.gradle
include ':app'
apply from: file("../node_modules/#react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings);
android/app/build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
}
}
apply plugin: 'com.android.application'
apply from: file("../../node_modules/#react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
repositories {
maven { url 'https://maven.google.com' }
}
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "com.myapp.android"
minSdkVersion 16
targetSdkVersion 29
versionCode 111
versionName "1.1.1"
multiDexEnabled true
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "org.webkit:android-jsc:+"
}
I was tried different methods but still same exception throwing.
Just add package name in your AndroidManifest.xml
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="example"
>
Related
I have tried to use ibm tone analyzer api for my project, but if I include the dependency I get this error:
Duplicate class javax.annotation.CheckForNull found in modules
annotations-3.0.1.jar (com.google.code.findbugs:annotations:3.0.1) and
jsr305-3.0.2.jar (com.google.code.findbugs:jsr305:3.0.2) Duplicate
class javax.annotation.CheckForSigned found in modules
annotations-3.0.1.jar (com.google.code.findbugs:annotations:3.0.1) and
jsr305-3.0.2.jar (com.google.code.findbugs:jsr305:3.0.2)
I have tried to delete testing dependencies, but still won't work, please help
App File:
apply plugin: 'com.android.application'
android {
configurations.all{
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
compileSdkVersion 28
defaultConfig {
applicationId "com.example.loginapp"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
compile 'com.ibm.watson:tone-analyzer:7.0.0'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude module: 'jsr305:3.0.2'
})
implementation 'com.google.firebase:firebase-auth:16.2.1'
}
// Add the following line to the bottom of the file:
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
Gradle Build file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url "https://dl.bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo"
}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
add applicationVariants.all to your gradle.build:
android {
applicationVariants.all { variant ->
variant.getRuntimeConfiguration().exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
}
I must update my app and I wanna know from someone much more experient than me in Android Studio development if my build.gradles (both) are ok to keep on coding.
<html>
<header><title>This is my build.gradle - Project</title></header>
<body>
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven { url 'https://maven.google.com' }
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
</body>
</html>
<html>
<header><title>This is my build.gradle -App</title></header>
<body>
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.elliottwaves.e_waves"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true // this prevents "not mocked" error
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
implementation 'androidx.annotation:annotation:1.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'
}
</body>
</html>
There is no Error when I sync Gradle but I can't run the charts yet. It's really new for me. Android Studio, Gradle and Maven differences, etc. My app is on as Beta and some details must be improved in code and even in design assets. So, I'd lovely enjoy somebody's Android Studio experience.
I followed google documentation to integrate my app to Google Analytics. But when adding on Module: app build.gradle
apply plugin: 'com.google.gms.google-services'
and building my app, I encountered this error:
Gradle sync failed: For input string: " 12"
My project build.gradle is:
plugins {
id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'io.fabric'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId 'xxx.xxxx.xxxxx'
minSdkVersion 19
targetSdkVersion 25
versionCode 74
versionName "1.0.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
manifestPlaceholders = [onesignal_app_id : "xxxxx-xxxxxx-xxx",
onesignal_google_project_number: "REMOTE"]
javaCompileOptions {
annotationProcessorOptions {
arguments = ['objectbox.debug': 'true']
}
}
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.facebook.android:facebook-login:[4,5)'
compile 'com.facebook.android:facebook-share:[4,5)'
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
implementation 'com.orhanobut:logger:2.2.0'
compile 'joda-time:joda-time:2.9.9'
compile('com.afollestad:bridge:5.1.2') {
exclude group: 'org.json', module: 'json'
}
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
compile 'jp.wasabeef:blurry:2.1.1'
compile 'com.makeramen:roundedimageview:2.3.0'
compile('com.redmadrobot:inputmask:2.3.0') {
exclude group: 'org.jetbrains', module: 'annotations'
}
compile 'se.emilsjolander:stickylistheaders:2.7.0'
compile 'com.daimajia.easing:library:2.0#aar'
compile 'com.daimajia.androidanimations:library:2.3#aar'
compile 'com.github.javadev:underscore:1.29'
compile 'com.onesignal:OneSignal:[3.7.1, 3.99.99]'
compile 'com.mixpanel.android:mixpanel-android:5.+'
compile 'com.github.thomper:sweet-alert-dialog:v1.4.0'
compile 'com.github.faranjit:currency-edittext:1.0.1'
compile 'org.apache.commons:commons-lang3:3.7'
compile 'com.google.guava:guava:24.1-android'
compile('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true
}
compile('com.github.worker8:tourguide:1.0.19-SNAPSHOT#aar') {
transitive = true
}
}
apply plugin: 'com.google.gms.google-services'
and app build.gradle is:
buildscript {
ext.objectboxVersion = '1.5.0'
repositories {
jcenter()
google()
mavenCentral()
maven { url "http://objectbox.net/beta-repo/" }
maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
maven { url "https://raw.githubusercontent.com/smilefam/SendBird-SDK-Android/master/" }
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.google.gms:google-services:3.3.1'
}
}
allprojects {
repositories {
jcenter()
google()
mavenCentral()
maven { url "http://objectbox.net/beta-repo/" }
maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
maven { url "https://raw.githubusercontent.com/smilefam/SendBird-SDK-Android/master/" }
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
if I remove apply
plugin: 'com.google.gms.google-services'
, the build normally works. But Firebase does not start correctly.
Reduce the version number of Google services. I had similar gradle sync error when using
com.google.gms:google-services:3.3.0
so I changed to
com.google.gms:google-services:3.2.1
and it worked.
Go to firebase and download your google-services.json and add it to your top level of your application.
I have updated Android Studio to 2.3 recently. When I try to open existing project which was running in AS 2.2 giving me below error in gradle:
Error:java.lang.NoClassDefFoundError: Could not initialize class
org.gradle.internal.resource.transport.http.AlwaysRedirectRedirectStrategy
When I restart AS it show's below error
Error:Unable to load class 'org.apache.commons.logging.LogFactory'.
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.
My project gradle is :
// 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.3.0'
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 {
jcenter()
}
repositories {
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My Module level gradle is:
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' }
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.6.6#aar') {
transitive = true;
}
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:leanback-v17:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId 'com.example.app'
minSdkVersion 15
targetSdkVersion 25
versionCode 3
versionName "1.0.2"
multiDexEnabled true
}
signingConfigs {
release {
keyAlias 'asda'
keyPassword 'asdas'
storeFile file('/home/.playstore/asda/asd.jks')
storePassword 'asda'
}
}
buildTypes {
release {
//shrinkResources true
//minifyEnabled true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
}
useLibrary 'org.apache.http.legacy'
repositories {
mavenCentral()
maven { url "https://repo.commonsware.com.s3.amazonaws.com" }
maven {
url "https://jitpack.io"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:multidex:1.0.1'
compile 'org.apache.commons:commons-io:1.3.2'
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: "httpclient"
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
//compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'joda-time:joda-time:2.9.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.github.Cutta:TagView:1.3'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
}
productFlavors {
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
apply plugin: 'com.google.gms.google-services'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "com.sample.app"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'maven'
repositories {
maven {
url "http://mycompany.com/nexus/content/repositories/mobile/Android/common/rest-api/1.0/"
artifactUrls "http://mycompany.com/nexus/content/repositories/mobile"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'Android.myApp:rest-api:1.0'
}
above the build.gradle file. When I execute gradle tasks I'm getting
A problem occurred configuring root project 'app'.
Could not resolve all dependencies for configuration ':_debugCompile'.
Could not resolve Android.myApp:rest-api:1.0.
Required by:
:app:unspecified
Target host must not be null, or set in parameters.
confirmed pom files and jar files are present in the maven repo.
Its silly.
maven {
url 'http:////mycompany.app.com/nexus/content/repositories/mobile'
}
url should contain 4 //// after http. We are using nexus and this fixes the issue.