Android Gradle sync failed (import project from github) - android

Hi guys i download a project from github and i imported in android studio , after imported am getting error
Gradle sync failed: Cause: assert localProps['keystore.props.file']
| |
| null
[ndk.dir:E:\sdk\ndk-bundle, sdk.dir:E:\sdk]
Consult IDE log for more details (Help | Show Log)
Gradle File:
signingConfigs {
release {
def Properties localProps = new Properties()
localProps.load(new FileInputStream(file('../local.properties')))
def Properties keyProps = new Properties()
assert localProps['keystore.props.file'];
keyProps.load(new FileInputStream(file(localProps['keystore.props.file'])))
storeFile file(keyProps["store"])
keyAlias keyProps["alias"]
storePassword keyProps["storePass"]
keyPassword keyProps["pass"]
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')
signingConfig signingConfigs.release
}
publicBeta.initWith(buildTypes.release)
publicBeta {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')
versionNameSuffix " Beta " + versionProps['betaNumber']
}
publicDebug.initWith(buildTypes.publicBeta)
publicDebug {
debuggable true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), file('proguard-project.txt')
versionNameSuffix " Debug Beta " + versionProps['betaNumber']
}
}
}
I realy don't know what to do.
Does anyone have any suggestions?.

In the root folder of your project, you should have keystore.properties and local.properties files.
keystore.properties should have something like this:
store=/path/to/your.keystore
alias=your_alias
pass=your_password
storePass=your_keystore_password
In local.properties, add the last line.
ndk.dir=/Users/username/Library/Android/sdk/ndk-bundle
sdk.dir=/Users/username/Library/Android/sdk
# Add the line below
keystore.props.file=../keystore.properties
See a commit here or check the modified project.
Or if you need a quick dirty fix, just make the gradle script the same as a standard one by replacing the android block with this:
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

When I got such an error, it was because I was using JDK8, while the imported github repo was using JDK7.
Also make sure you have "Android Support Repository" installed from SDK Manager > Extras.

Related

D8 does not support main-dex inputs and outputs when compiling to API level 21 and above

I am facing this error during the build:
"D8 does not support main-dex inputs and outputs when compiling to API level 21 and above"
If i set minifyEnabled to true in debug buildType everything works fine, but if i set it to false i just get this error.
My gradle file:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.generalbytes.batm"
minSdkVersion 17
targetSdkVersion 22
multiDexEnabled true
ndk {
abiFilters 'armeabi-v7a'
}
}
useLibrary 'org.apache.http.legacy'
testOptions {
unitTests.all {
enabled !useDummyBitRafael.toBoolean()
}
}
signingConfigs {
release {
storeFile rootProject.file(releaseStoreFile)
storePassword releaseStorePassword
keyAlias releaseKeyAlias
keyPassword releaseKeyPassword
}
debug {
storeFile rootProject.file(releaseStoreFile)
storePassword releaseStorePassword
keyAlias releaseKeyAlias
keyPassword releaseKeyPassword
}
}
buildFeatures {
dataBinding = true
viewBinding = true
}
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
lintOptions {
tasks.lint.enabled = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
testOptions {
unitTests.returnDefaultValues = true
}
Any ideas?
I just click "refresh gradle dependencies" from Android studio Gradle view and then the problem disappear.

Apk size increased drawable-xxxhdpi-v4

I am unable to figure this out. My apk size has increased by at least another MB since the last release. Yes, I have added some new code and couple of vector assets thats it. But there is this drawable-xxxhdpi-v4 which got added to my apk and my png images are repeated there.
Take a look.
Has anybody faced this?
I just cant seem to figure out why is this hapenning. Its not even like these are new images. The old ones which were 0 bytes in this folder are now occupying space.
Gradle version 2.14.1
Plugin version 2.2.3
App build.gradle:
defaultConfig {
applicationId project.APPLICATION_ID
minSdkVersion Integer.parseInt(project.ANDROID_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_TARGET_SDK_VERSION)
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
resConfigs "en", "fr"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
lintOptions {
abortOnError false
disable 'MissingTranslation'
}
dataBinding {
enabled = true
}
dexOptions {
preDexLibraries = false
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
noCompress "db"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
def BOOLEAN = "boolean"
def TRUE = "true"
def FALSE = "false"
def LOGGING = "LOGGING"
def STRICT_MODE = "STRICT_MODE"
def DEBUG_MODE = "DEBUG_MODE"
release {
minifyEnabled true
proguardFiles 'proguard-rules.txt', 'proguard-here-sdk.txt'
// Resource shrinking confis
shrinkResources true // remove unused resources
signingConfig signingConfigs.release
debuggable false
buildConfigField BOOLEAN, LOGGING, FALSE
buildConfigField BOOLEAN, STRICT_MODE, FALSE
buildConfigField BOOLEAN, DEBUG_MODE, FALSE
zipAlignEnabled true
applicationVariants.all { variant ->
if (variant.buildType.name == 'release') {
variant.mergeAssets.doLast {
delete(fileTree(dir: variant.mergeAssets.outputDir, includes: ['ic_launcher_debug*']))
}
}
}
}
lintOptions {
disable 'InvalidPackage'
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
The below config worked for me
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
Yes. When you compile with Coccoon.io an android version of your app, it happens the same. The size of the app is increased at double. This is not only due to folders like this, but for the libraries Coccoon puts on the app for cordova.
I donĀ“t know if that will help you, but al least is a clue.

Override debug build type signing config with flavor signing config

I've got an Android app that has 2 flavors: internal and production, and there are 2 build types as well: debug and release.
I'm trying to assign signing configs based on the flavor, which according to the documentation is doable. I've looked and found other answers to this, but none of them seem to work. Everything compiles, but the app is being signed with the debug keystore local to my machine.
Here is my gradle file:
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0.0"
}
signingConfigs {
internal {
storeFile file("../internal.keystore")
storePassword "password"
keyAlias "user"
keyPassword "password"
}
production {
storeFile file("../production.keystore")
storePassword "password"
keyAlias "user"
keyPassword "password"
}
}
productFlavors {
internal {
signingConfig signingConfigs.internal
applicationId 'com.test.test.internal'
}
production {
signingConfig signingConfigs.production
applicationId 'com.test.test'
}
}
buildTypes {
debug {
applicationIdSuffix ".d"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
variantFilter { variant ->
if (variant.buildType.name.equals('debug')
&& variant.getFlavors().get(0).name.equals('production')) {
variant.setIgnore(true);
}
}
}
Note: I'm also compiling with classpath 'com.android.tools.build:gradle:1.1.3'
It seems that by default, Android has a signingConfig set on the debug build type (the android debug keystore), and when the signingConfig is set for the build type, the signingConfig is ignored for the flavor.
The solution is to set the signingConfig to null on the debug build type. Then the signingConfig given for the flavor will be used instead:
buildTypes {
debug {
// Set to null to override default debug keystore and defer to the product flavor.
signingConfig null
applicationIdSuffix ".d"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

Gradle Warning: missing groovy return statement

I'm having the following warning in my gradle build file
Not all execution paths return a value
This inspection reports on missing groovy return statement at the end of methods returning
and this is the code in that file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "ac.company.srikar.quickhelpindia"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
}
Can anyone tell what is the issue here and how to get rid of this warning.
With Android Studio 2.2 I had to add a return void before the final bracket in the android section.
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
standard {
applicationId "com.example.app.standard"
}
free {
applicationId "com.example.app.free"
}
}
// `return void` removes the lint error: `Not all execution paths return a value`.
return void
}
I have been getting this same warning and I think it is incorrect. I have read through the gradle documentation and it does not appear that a return type is needed. However, the warnings bug me and the only way I could get rid of it was to add return true.
buildTypes {
android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
return true
}
}
}
I doubt this is the "correct" solution; however, it does remove the warnings and it doesn't cause any issues.
I fixed this by adding the recommended suppression string from inspection:
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 25
buildToolsVersion "23.0.3"
...
I got rid of this warning when I specified both, minifyEnabled and shrinkResources.
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
It seems that this is an issue fixed in Android Studio 2.3:
https://code.google.com/p/android/issues/detail?id=223575

debuggable false in android studio 0.4.5

<application
android:debuggable="false"
get a error saying "Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one"
I deleted what is up in AndroidManifest and I add this in the build.gradle
android {
compileSdkVersion 18
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 7
targetSdkVersion 19
versionCode 3
versionName "1.2"
}
buildTypes {
debug {
debuggable true
jniDebugBuild true
}
release {
debuggable false
jniDebugBuild true
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile files('build/libs/GoogleAdMobAdsSdk-6.4.1.jar')
}
but still does not work when i upload to play store
thanks
This is what I used and it worked perfectly
buildTypes {
debug {
debuggable false
}
release {
runProguard false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

Categories

Resources