Gradle settings for this project are not configured yet - android studio - android

I'm trying to load an existing project and i'm running into these problems:
clicking ok i will have this:
Searching here I have not found grangle 2.2.2. Minimum grandle is 3.0.0
build.grandle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
app.build.grande:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.prouast.heartbeat"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
// add a task that calls regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath, // relative path to jni source
'NDK_LIBS_OUT=../jniLibs',
'-j', Runtime.runtime.availableProcessors(),
'all',
'NDK_DEBUG=1'
}
task ndkClean(type: Exec, description: 'Clean JNI object files') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build",
'-C', file('src/main/jni').absolutePath, // relative path to jni source
'NDK_LIBS_OUT=../jniLibs',
'clean'
}
// add this task as a dependency of Java compilation
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn(['ndkBuild'])
}
clean.dependsOn(['ndkClean'])
sourceSets.main {
jni.srcDirs = []
//jniLibs.srcDir 'src/main/libs'
}
buildTypes {
debug {
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'org.apache.commons:commons-io:1.3.2'
compile 'com.android.support:appcompat-v7:23.1.1'
compile project(':libraries:opencv')
}
Need I to change something on app grandle or anybody have some suggestion?
Could you suggest me some links to follow or explain step by step how can I solve it?
EDIT :
adding the jcenter to gradle.build resolves the issue:
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}

Click Ok for gradle wrapper or go manually at build.gradle and update the following line :
**classpath 'com.android.tools.build:gradle:3.2.1'**

Just click OK for Studio to automatically perform the Gradle configuration.

Related

Bridging an native android SDK - heremaps

Currently I am trying to bridge the Heremaps android sdk for react-native via external library. I have successfully bridged it in a local react-native project and am currently in the process of creating the android portion of the library.
Currently with the current implementation I have, I am running into this error when I try to run an android build:
What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
Could not find :HERE-sdk:.
Required by:
project :app > project :react-native-heremaps-bridge
The sdk lives in {libraryname}/android/app/libs in my external library
My android/app build.gradle in the external library looks likes this.
apply plugin: 'com.android.library'
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}
repositories {
flatDir {
dirs 'libs'
}
}
android {
compileSdkVersion safeExtGet("compileSdkVersion", 28)
buildToolsVersion safeExtGet("buildToolsVersion", '28.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 17)
targetSdkVersion safeExtGet('targetSdkVersion', 26)
versionCode 1
versionName "1.0" nb
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
// React Native
implementation "com.facebook.react:react-native:+"
// HereMaps SDK
implementation(name:'HERE-sdk', ext:'aar')
}
and android level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 17
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
}
repositories {
google()
jcenter()
}
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 {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
flatDir {
dirs 'libs'
}
}
}
On the react-native side, my build.gradle on android/app level only has these changes:
dependencies {
implementation project('{project-name}')
}
And my settings.gradle include these changes:
include ':{library name}'
project(':{library name}').projectDir = new File(rootProject.projectDir, '../node_modules/{library name}/android/app')
And lastly in my MainApplication.java:
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for
// example:
packages.add(new HeremapsPackage()); //<------added this line
return packages;
}
Any idea what I'm missing here? I would like to avoid adding the sdk in my main react-native app as that's close to 100mbs. Thank you!
The gradle buildTypes should be same at root and app level to resolve the dependencies. Also If you are using lite version, you can think of upgrading the version of sdk.
buildTypes{
debug{ ... }
release{ ... }
}
you have in your (app) build.gradle file, You have to include all the buildTypes{ } with same names as like
buildTypes{
debug{ ... }
release{ ... } }
in to build.gradle files of All libraries/modules included in project.
clean and rebuild the project, the issue should be fixed.

Execution failed for task ':app:processDebugGoogleServices' for react native after adding Firebase

I have added React Native Firebase. I have used rnfirebase module as that seems lot easier. After adding RNFirebase to my project, I am starting to get this error while compiling
Execution failed for task ':app:processDebugGoogleServices'
This is my build.gradle file (project).
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
apply plugin: 'com.google.gms.google-services'
And this is my build.gradle file for app.
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.instantstories"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
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 {
implementation project(':react-native-firebase')
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.firebase:firebase-core:16.0.3"
implementation project(':react-native-photo-view')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-vector-icons')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
Anything wrong with my gradle file? I tried many SO answers but none of them seems to work. I even tried adding the project on android studio, but that didn't help either. Anything I could do more than that?
I had the same issue. I fixed it by deleting a line apply plugin:'com.google.gms.google-services'.
you can find it in your app/build.gradle.
because "com.android.application" package already has same package.
If you think you already have your latest google-services.json file added to your project then try running the command below in the root folder of your project and try running your project again.
cd android && gradlew clean
cd ..
react-native run-android
I am using firebase ,in my case, I failed to put a google-services file inside in android/app.. Make Sure that You placed google-services.json in android/app/{here}.

SIPdroid Android Studio ndk integration error

I'm currently using Android Studio 2.0 preview 4. I have followed the guide from tools.android.com and tested NDK samples from github. The samples worked without a hitch, but when I implemented it on the SIPdroid project, it throws this error when I rebuild the project:
Error:(78, 1) A problem occurred configuring project ':app'.
Exception thrown while executing model rule: model.android
Cannot set readonly property: minSdkVersion for class: com.android.build.gradle.managed.ProductFlavor_Impl
when I try to use gradle project sync it gives this error:
Error:Unable to load class 'com.android.build.gradle.managed.ProductFlavor_Impl'.
Possible causes for this unexpected error include:You are using JDK version 'java version "1.7.0_79"'. Some versions of JDK 1.7 (e.g. 1.7.0_10) may cause class loading errors in Gradle.
Please update to a newer version (e.g. 1.7.0_67).
Open JDK SettingsGradle'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.
Android project structure now looks like this. previously the jni folder is separated from the java folder.
Here's my config:
SIPdroid/app/build.gradle
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.2"
defaultConfig.with {
applicationId = "com.test.sipdroid"
minSdkVersion = 15
targetSdkVersion = 23
versionCode = 1
versionName = "1.0"
}
}
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
/*
* native build settings
*/
android.ndk {
moduleName = "SIPdroid"
/*
* Other ndk flags configurable here are
* cppFlags.add("-fno-rtti")
* cppFlags.add("-fno-exceptions")
* ldLibs.addAll(["android", "log"])
* stl = "system"
*/
}
android.sources {
main.java {
source {
srcDir 'src'
}
}
main.jni {
source {
srcDirs = []
}
}
main.jniLibs {
source {
srcDirs = ['src/main/libs']
}
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
android.productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" #
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
SIPdroid/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-experimental:0.4.0'
// classpath 'com.android.tools.build:gradle:1.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
SIPdroid/gradle-wrapper.properties
#Mon Jan 04 16:06:26 PHT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
SIPdroid/local.properties
ndk.dir=/path/Android/sdk/ndk-bundle
sdk.dir=/path/Android/sdk
I just recently solved my issue by adding this to my orignal app/build.gradle file without using the experimental gradle build ('com.android.tools.build:gradle-experimental:0.4.0') as indicated in the google samples.
This solution finally solved the issue NDKBuild Failure. This additional script builds your jni files using ndkBuild.
app/build.gradle
sourceSets.main {
jniLibs.srcDir 'src/main/libs' // use the jni .so compiled from the manual ndk-build command
jni.srcDirs = [] //disable automatic ndk-build call
}
task ndkBuild(type: Exec) {
// commandLine 'ndk-build', '-C', file('src/main/jni').absolutePath <-- Not working
commandLine '/home/user/Android/sdk/ndk-bundle/ndk-build', '-C', file('src/main/jni').absolutePath
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
SIPdroid/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
}
You also need to have an empty libs folder under app/src/main. My mistake was that I renamed the /jni folder to /libs. After running the build, it will compile your jni to the /libs folder to .so files
jniLibs in your Android project structure view will look like this. This is from your app/src/main/libs as indicated in your build.gradle script
I hope this helps.

Can't build Tango c examples

I downloading the Tango C examples and opened point-cloud-jni-example in Android Studio. I have ndk installed and added ndk.dir=E:\Android\sdk\ndk-bundle to my local.properties file. Gradle syncs without errors, but when I run, I get this error:
Error:Execution failed for task ':app:ndkBuild'.
A problem occurred starting process 'command 'E:\Android\sdk\ndk-bundle/ndk-build''
I get the same error with motion-tracking-jni-example and hello-tango-jni-example and I assume the others as well.
What am I doing wrong?
build.gradle (app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.projecttango.experiments.nativepointcloud"
minSdkVersion 19
targetSdkVersion 19
}
sourceSets.main {
jniLibs.srcDir 'src/main/libs'
jni.srcDirs = [];
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
task ndkBuild(type: Exec) {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build"
commandLine ndkbuild, '-C', file('src/main/jni').absolutePath
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
build.gradle (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.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
My system:
Windows 8.1 64 bit
Android Studio 1.3 (AI-141.2117773)
NDK r10e extracted to E:\Android\sdk\ndk-bundle
Device: Project Tango Tablet with Schur core
You need to append '.cmd' to the ndkbuild command. By that, I mean that the line
def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build"
should read
def ndkbuild = properties.getProperty('ndk.dir', null)+"/ndk-build.cmd"
It was no fault of your own, I noticed the same issue when I went to compile on my Surface.

how to rename android package name using gradle on cmd?

i want to rename package name using gradle on cmd.because i have multiple project customization and change package name using ide very difficult to change each package name separately.please give me solution.thanks in advance
apply plugin: 'com.android.application'
apply plugin: 'maven'
android {
compileSdkVersion 21
buildToolsVersion "23.0.0 rc2"
sourceSets {
defaultConfig {
applicationId "com.appbell.restaurant.genericresto"
minSdkVersion 14
targetSdkVersion 19
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
main {
manifest.srcFile 'src\\main\\AndroidManifest.xml'
println('android'+manifest.srcFile)
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
task changePackage{
replaceInManifest("com.appbell.restaurant.example","com.appbell.imenu4u")
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
// Make sure this is at least 0.10.+
classpath 'com.android.tools.build:gradle:1.0.+'
}
}
task appStart(type: Exec, dependsOn: 'installDebug') {
// linux
//commandLine 'adb', 'shell', 'am', 'start', '-n', 'com.example/.MyActivity'
// windows
commandLine 'cmd', '/c', 'adb', 'shell', 'am', 'start', '-n', 'com.appbell.restaurant.genericresto/com.appbell.and.resto.and.ui.SplashActivity'
}
dependencies {
compile project(':facebook')
compile project(':stripe')
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:21.0.3'
compile files('libs/mobileappclasses.jar')
compile files('libs/pgsdk.jar')
}
def replaceInManifest(fromString, toString) {
def manifestFile = "C:\\Users\\Ntin Gorle\\AndroidstudioProjects\\MyApplication\\RestoAppNEw\\src\\main\\AndroidManifest.xml"
def updatedContent = new File(manifestFile).getText('UTF-8').replaceAll(fromString, toString)
new File(manifestFile).write(updatedContent, 'UTF-8')
}
I this code package name change but not reflect in all .java file.please tell me how to change in all .java classes.
If you need to change the package name often and in multiple projects. I recommend the plugin "Android Package Renamer", it's available on the Android Studio plugin market and Intellij IDEA. All you need to do is download it and use it. It works well on many different types of projects.
Usage
Open Your Project.
Click -> File -> Rename Package
Input the Package you want to change.
Click Ok.
Sync Project with Gradle Files or Invalidate Caches
You can see my detailed answer here or head over to the github repo for a closer look at the instructions.

Categories

Resources