Closed npomfret closed 7 years ago
Hi @npomfret and thank you for using this tool. Would you mind checking if you installed the "Android Support Repository" in your Android SDK manager?
Yes, Android Support Repository is installed (version 35.0.0)
Any update on this? Has anyone managed the get the generated android project to work in android studio? How do you use it if not?
After much hacking around with the generated gradle file, I ended up with the following that seems to make android studio happy. The trick seems to be to tell gradle about jcenter, twice. Oh, and to tell gradle about gradle...
//this bit is new
build script {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
idk {
abiFilters "armeabi-v7a", "x86"
}
}
lintOptions {
warning 'InvalidPackage'
}
}
//this bit is new
all projects {
repositories {
jcenter()
}
}
dependencies {
compile 'com.facebook.react:react-native:0.20.+'
}
I didn't want to submit it as a PR (yet) as I have no idea what the changes I've made actually mean. Gradle is a total mystery to me and I wouldn't want even to suggest this going in without some discussion.
Has anyone managed to get the java project working in Android studio without making these modifications to the generated gradle file?
I got the same error but couldn't get it to work with your gradle file either 😞
What I got working was the following:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
lintOptions {
warning 'InvalidPackage'
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.facebook.react:react-native:+'
}
I've asked about setting up android build files that don't compile on a few other repos. It seems to me (in general) that a lot of react-native people just don't care about compiling java code in isolation of a project. People commonly build RN native libraries that just don't compile unless you embed them in another project... which seems like madness to me. In some RN library projects, most (maybe 99%) of the code has nothing to do with RN, its just pure java. And it should be compilable and testable in isolation in my opinion. But I don't know how to convince others of this. This project is a good example. I think everything in here would work IF you embedded the library you create into a fully functional RN project.
Yeah I had that exact issue, I do depend on com.facebook.react
packages, but from what I saw the latest version on Maven is 0.20 and I used APIs that were newer than that. So I had to compile my project with an RN app in order to get the latest com.facebook.react
jar from node_modules/react-native
.
I just released version 3.0.0
which includes these fixes to the build.gradle
file. Thank you for reporting the issue and investigating this 👍
@npomfret For what its worth, Gradle is a mystery to the whole world !! The amount of time this thing consumes if trying to debug is absolutely ridiculous. I have had problem after problem with a fairly large project. Fix one thing and something else complains. The incompatibilities between Gradle and Studio and other, the deprications, it's just crazy. Yep you're right, I am not happy :)
By the way @npomfret and @vikeri thanks for the suggestions, didn't work for me unfortunately so I will keep running in circles.
@npomfret For what its worth, Gradle is a mystery to the whole world !! The amount of time this thing consumes if trying to debug is absolutely ridiculous. I have had problem after problem with a fairly large project. Fix one thing and something else complains. The incompatibilities between Gradle and Studio and other, the deprications, it's just crazy. Yep you're right, I am not happy :)
By the way @npomfret and @vikeri thanks for the suggestions, didn't work for me unfortunately so I will keep running in circles.
I totally agree that gradle is piece of shit and should be erased from this world.
The default android project doesn't seem to work for me. I get the errors:
What am I doing wrong?