How to configure build.gradle - android

I'm trying to add cppFlags, but always report error:
"Error:(16, 0) Could not find property 'cppFlags' on com.android.build.gradle.internal.dsl.NdkOptions_Decorated#44658d55.
Open File"
Please help me, thanks!
Here are my gradles:
top 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:2.1.2'
// classpath 'com.android.tools.build:gradle-experimental:0.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "andrewl.videowall"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName = "HelloARVideoNative"
// cppFlags.add("-I${file("include")}".toString())
cppFlags.add("-DANDROID")
cppFlags.add("-fexceptions")
cppFlags.add("-frtti")
stl = "gnustl_static"
ldLibs "log","GLESv2"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/java-gen']
jniLibs.srcDirs = ['libs']
}
}
productFlavors {
create("arm") {
ndk.with {
abiFilters.add("armeabi-v7a")
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/greendao-1.3.7.jar')
}
gradle wrapper
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

Have look at this. this example contains configuration what you need in your cpp supported application.
ndk {
moduleName = 'hello-jni'
toolchain = 'clang'
CFlags.addAll(['-Wall'])
}
Source

Related

Could not GET 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.0.1/google-services-4.0.1.pom'

Getting error while using Add Firebase Authentication to your App in the Firebase authentication (Assistant).
The error shows in the Sync tab as:
Could not GET 'https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.0.1/google-services-4.0.1.pom'. Received status code 405 from server: Method Not Allowed
Enable Gradle 'offline mode' and sync project
My Android Studio Details are:
Android Studio version 3.2.1
Gradle version: 4.6
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/android/android-tools' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
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()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (App)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.nsc.suyog.myotp1"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
}
Try to change the following code (project):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven { url "http://jcenter.bintray.com"}
maven { url 'https://dl.bintray.com/android/android-tools' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.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 {
google()
maven { url "http://jcenter.bintray.com"}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And (app):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.nsc.suyog.myotp1"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
android { lintOptions { abortOnError false }
aaptOptions {
cruncherEnabled = false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-auth:16.1.0'
}
Also in gradle-wrapper.properties add this line or change if already exist with other value:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Just remove :15.0.0 from the firebase implementation!
The implementation should be like:
implementation 'com.google.firebase:firebase-auth:16.1.0'
Else every thing seems fine!

Android Studio and protobuf Error:(7, 0) Plugin with id 'com.google.protobuf' not found

I want to use grpc in Android Studio, but failed in gradle setting.
my gradle plugin version is 2.1.2. I have installed gradle 2.14.
In my app\build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
apply plugin: "com.google.protobuf"
defaultConfig {
applicationId "com.example.test.test_20"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
jniDebuggable true
}
}
buildscript {
repositories {
maven {
mavenCentral()
}
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0"
}
}
protobuf {
protoc {
// The version of protoc must match protobuf-java. If you don't depend on
// protobuf-java directly, you will be transitively depending on the
// protobuf-java version that grpc depends on.
artifact = "com.google.protobuf:protoc:3.0.0"
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.0.0'
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'io.grpc:grpc-okhttp:1.0.0'
compile 'io.grpc:grpc-protobuf-lite:1.0.0'
compile 'io.grpc:grpc-stub:1.0.0'
}
Gradle sync message output is
Error:(7, 0) Plugin with id 'com.google.protobuf' not found.
What is wrong in my setting?
I create a new empty project, and app/build.gradle file:
apply plugin: 'com.android.application'
apply plugin: "com.google.protobuf"
buildscript {
repositories {
maven {
//mavenCentral()
url 'https://repo1.maven.org/maven2'
}
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0"
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.test.testprotobuf"
minSdkVersion 15
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.4.0'
compile 'com.android.support:design:23.4.0'
}
And gradle-wrapper.properties file:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
I excute "gradlew build" command successfully.
And sync gradle, it prompt that “Error:(2, 0) Cause: org/gradle/api/internal/file/collections/DefaultDirectoryFileTreeFactory
” 。
Something wrong in your build.gradle. You have to move some parts:
apply plugin: 'com.android.application'
apply plugin: "com.google.protobuf"
buildscript {
repositories {
maven {
mavenCentral()
}
}
dependencies {
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0"
}
}
android {
}
you must add the following code in the build.gradle(the project's build.gradle, not the app's):
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// for gRPC
classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.0"
}}

How to configure build.gradle files of an existing project with tess-two lib?

For image processing i want to sync tessaract OCR in Android..i dont knw how to sync..!! when i tried to do some changes it shows "gradle sync failed"..
Here is setting.gradle and build.gradle
// setting.gradle:
include ':app'
include ':libraries:tess-two'
build.gradle of MyApplication:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.raghavan.myapplication"
minSdkVersion 15
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.2.1'
compile 'com.android.support:design:23.2.1'
}
build.gradle of tess-two:
// 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.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
apply plugin: 'android-library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
}
sourceSets.main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
jniLibs.srcDirs = ['libs']
}
}

Gradle not working with android studio

I've tried everything I've found on the ointernet with all the error messages i found. Styles are missing, gradle can't sync and nothing is working. Help please
build.gradle (Project:MyApplication)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.utente.myapplication"
minSdkVersion 18
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
maven { url 'http://repo1.maven.org/maven2' }
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:21.0.3'
}

How to add Crop Library Github

I want to add SimpleCropView to my Android Project from Github https://github.com/IsseiAoki/SimpleCropView but dont know how to proceed.My Project Gradle file are as follows.
Project 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:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Module Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "loginscreen.example.com.girviapp"
minSdkVersion 12
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:design:22.2.0'
compile files('libs/dropbox-android-sdk-1.6.3/dropbox-android-sdk-1.6.3.jar')
compile files('libs/dropbox-android-sdk-1.6.3/json_simple-1.1.jar')
compile files('libs/jcifs-1.3.18.jar')
}
Include the following dependency in your build.gradle file.
dependencies {
compile 'com.isseiaoki:simplecropview:1.0.8'
}

Categories

Resources