I have an problem
My gradle setting
build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "hanium.project.androidapp_picturehawk"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/*
* native build settings: taking default for almost everything
*/
ndk {
moduleName = 'hello-jni'
toolchain = 'clang'
CFlags.addAll(['-Wall'])
}
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") {`enter code here`
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:24.1.1'
}
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:2.1.2'
classpath 'com.android.tools.build:gradle-experimental:0.7.2'
// 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
}
----------------------------------------------
but i have an error
Error:(24, 0) Gradle DSL method not found: 'ndk()'
Possible causes:<ul><li>The project 'AndroidApp_PictureHawk' may be using a version of Gradle that does not contain the method.`enter code here`
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
what should I do??
please help me
Read your error message!
Possible causes:<ul><li>The project 'AndroidApp_PictureHawk' may be using a version of Gradle that does not contain the method.`enter code here`
Then look for and remove enter code here:
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") {`enter code here`
ndk.abiFilters.add("armeabi-v7a")
}
Related
I searched a lot on the web, but couldn't find a solution. I have a a project named VolleyLib with a library module named volleylib. I'm trying to publish the library on mavenLocal repo, but when build the project no publishing task is executed (only prepareLintJarForPublish). And of course nothing goes into .m2 folder (which I created myself after installed maven...). I can't really get why and what is wrong. Probably something's missing...
Here's my build.gradle for volleylib module:
plugins {
id 'com.android.library'
id 'maven-publish'
}
android {
compileSdk 31
defaultConfig {
minSdk 22
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.13.1'
implementation 'androidx.room:room-common:2.4.1'
annotationProcessor 'androidx.room:room-compiler:2.4.1'
implementation 'androidx.room:room-coroutines:2.1.0-alpha04'
implementation 'androidx.room:room-runtime:2.4.1'
implementation 'androidx.room:room-migration:2.4.1'
implementation 'androidx.room:room-rxjava2:2.4.1'
}
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'com.example.VolleyLib'
artifactId = 'final'
version = '1.0'
}
// Creates a Maven publication called “debug”.
debug(MavenPublication) {
// Applies the component for the debug build variant.
from components.debug
groupId = 'com.example.VolleyLib'
artifactId = 'final-debug'
version = '1.0'
}
}
repositories {
mavenLocal()
}
}
}
Any help would be greatly appreciated.
It's the first time I try this, so apologize if it's a trivial question...
Thank you all in advance.
My working library build.gradle is almost like yours. Except, it doesn't use the following:
plugins {
id 'com.android.library'
id 'maven-publish'
}
but the following:
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
And I'm using Java 8 for compileOptions block:
android {
...
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
And, lastly, without repositories in afterEvaluate:
afterEvaluate {
publishing {
...
// Remove the following commented line:
// repositories {
// mavenLocal()
// }
}
}
Then, to build and install the library to maven local, click gradle icon on the left menu of Android Studio. Then select projectName -> libraryName -> Run Configuration -> publishToMavenLocal.
UPDATE:
Here the complete build.gradle.
root build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.1'
}
}
repositories {
mavenCentral()
}
allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
google()
}
}
ext {
compileSdkVersion = 31
buildToolsVersion = '30.0.2'
minSdkVersion = 16
targetSdkVersion = 31
junitVersion = '4.13.2'
androidxAppcompatVersion = '1.4.1'
androidApplicationId = 'com.project.sample'
androidVersionCode = 1000
androidVersionName = "1.0.0"
androidAppName = 'Sample'
}
my library build.gradle (jcplayer library in root/jcplayer directory):
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation "androidx.appcompat:appcompat:$androidxAppcompatVersion"
}
// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
jcplayer(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = rootProject.ext.androidApplicationId
artifactId = 'jcplayer'
version = rootProject.ext.androidVersionName
}
}
}
}
I tried to use a new parse sdk from github but after installing android studio throwing below error.
Error:No resource identifier found for attribute 'appComponentFactory' in package 'android'
Error:Execution failed for task ':app:processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
Attaching the gradle files. Please help if there are any issues to be fixed.
App gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.example.ashwini.test"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
aaptOptions {
cruncherEnabled = false
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.parse-community.Parse-SDK-Android:parse:1.23.0'
testCompile 'junit:junit:4.12'
}
Module gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven {url 'http://jitpack.io'}
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven {
url 'https://maven.google.com'
}
}
}
ext {
compileSdkVersion = 27
buildToolsVersion = "27.0.3"
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I run the Android App in Android Studio, I get the following error:
Error:Build Config field cannot have a null parameter
Consult IDE log for more details (Help | Show Log)
'build.gradle' file code:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
'gradle-wrapper.properties' file code:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Here is the below 'build.gradle' code inside the app subfolder. It has something called 'google_nearby_api_key'. Not sure if that's causing the issue:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.25.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
jcenter()
google()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://jitpack.io' }
}
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.sg.blahblah"
minSdkVersion 21
targetSdkVersion 27
versionCode 24
versionName "1.0.4"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
def filesAuthorityValue = applicationId + ".files"
manifestPlaceholders = [filesAuthority: filesAuthorityValue]
buildConfigField "String", "FILES_AUTORITY", "\"${filesAuthorityValue}\""
resValue "string", "google_nearby_api_key",
getLocalProperties().getProperty("google_nearby_api_key")
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE'
exclude 'LICENSE.txt'
exclude 'NOTICE'
exclude 'asm-license.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:cardview-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.google.android.gms:play-services-nearby:11.8.0'
implementation 'com.google.android.gms:play-services-appinvite:11.8.0'
implementation 'com.google.android.gms:play-services-analytics:11.8.0'
// Dagger
implementation 'com.google.dagger:dagger:2.14'
annotationProcessor 'com.google.dagger:dagger-compiler:2.14'
// Logging
implementation 'com.jakewharton.timber:timber:4.5.1'
// View injection
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
// Database
implementation 'com.j256.ormlite:ormlite-android:4.48'
// Fonts
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
// Image loading
implementation 'com.squareup.picasso:picasso:2.5.2'
// Crop avatar
implementation 'com.lyft:scissors:1.0.1'
// JSON serialization
implementation 'com.google.code.gson:gson:2.8.2'
// Crash & usage monitoring
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true;
}
// Generate fake data
implementation 'com.github.blocoio:faker:1.2.5'
// Testing
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.10.0'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support:support-annotations:27.0.2'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
androidTestImplementation('com.android.support.test.espresso:espresso-contrib:3.0.1') {
exclude module: 'recyclerview-v7'
exclude module: 'support-v4'
}
}
apply plugin: 'com.google.gms.google-services'
def getLocalProperties() {
Properties properties = new Properties()
properties.load(new File(rootDir.absolutePath + "/local.properties").newDataInputStream())
return properties
}
Can you please help?
Thanks in advance
This seems to come from here:
resValue "string", "google_nearby_api_key",
getLocalProperties().getProperty("google_nearby_api_key")
I guess the property google_nearby_api_key is not defined.
I tried to run my app and got this erro, help me please.
// 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.2.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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
signingConfigs {
config {
}
}
buildToolsVersion '24.0.2'
compileSdkVersion 24
buildTypes {
buildType {
signingConfig signingConfigs.config
}
}
}
dependencies {
}
ERROR:
Error:(22, 0) Could not find method android() for arguments
[build_exkifxt5bplscorlvh4v3btv2$_run_closure3#981984c] on root
project 'Recipe App' of type org.gradle.api.Project.
Add this line:
apply plugin: 'com.android.feature'
To the top of the problematic build.gradle file and sync again.
I faced same problem and SOLVED IT BY:
Open your ‘build.gradle’ file and you find the following may be your comiple version is different but I want t show the file structure.
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
}
dependencies {
}
The error happens because similar android declaration is in other build.gradle file. therefore remove both the android and dependencies.
for more details here
// 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.1'
// 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
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile files('app/libs/junit-4.12-JavaDoc.jar')
}
apply plugin: 'maven'`enter code here`
I am trying to run a project that I found on github, This is the link to the project. I tried to put it in android studio, Unfortunately I cant create a configuration to run for that project. Its a library project. How can I install it. There is no modules appearing for this project. This is the gradle file
buildscript {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1"
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
}
apply plugin: 'com.android.library'
apply plugin: "com.github.hierynomus.license"
license {
license {
header = file('HEADER.txt')
skipExistingHeaders = true
ignoreFailures = false
}
}
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.1-1'
}
def isReleaseBuild() {
return project.VERSION_NAME.contains("SNAPSHOT") == false
}
apply from: './maven_push.gradle'
Since it is a library you can only run with a app that you are developing and not run it as stand alone.