I created an app which uses native codes, when I compile it Android Studio in debug type app works perfectly but when I generate a signed aab file, the jniLibs files get compressed and it breaks functionality in the app. I would like to know if I can exclude the lib files from being compressed.
This is my project build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
maven { url "https://dl.bintray.com/yahoo/maven/" }
//maven { url "https://repo1.maven.org/maven2/" }
maven { url "https://repo.spring.io/plugins-release/" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
This is my app build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 32
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.xxxxx.xxxxxxx"
minSdkVersion 21
targetSdkVersion 32
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation files('libs/achartengine-1.2.0.jar')
api 'com.android.support:cardview-v7:25.+'
api 'com.android.support:appcompat-v7:25.+'
api 'com.android.support:preference-v7:25.+'
api 'com.android.support:design:25.+'
These are the lib files when the app is compiled in debug type:
Original lib files
Lib files when I generate signed aab in android studio:
aab lib files
In debug build the app works perfectly.
In signed generated aab, the libs are compressed, as seen in the second screenshot, this breaks the libpdnsd.so and libtun2socks.so.
This is the result
If there is a way to maintain the original libs when generating aab please let me know.
Any solution is welcomed.
You just not linked the lib folder to your app App (build.gradle). And also you have to add this line android:extractNativeLibs="true" to your AndroidManifest.xml
You can do it following like this.
First add this to your AndroidManifest.xml
android:extractNativeLibs="true"
Link the lib folder to your App (build.gradle)
android {
sourceSets {
all {
jniLibs.srcDirs = ["lib"]
}
}
}
Sync it
Related
I am trying to implement any kind of dependency ,in new android studio IDE which is stable in JDK 11, like payumoney or something else. It syncs successfully but when trying to use it in java file or xml file getting error like can not find symbol that you are using.
In updated Android Studio when we create new project we are getting code in build.gradle file which is given below :
build.gradle :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.2' apply false
id 'com.android.library' version '7.1.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and build.gradle(app) :
plugins {
id 'com.android.application'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.wipenex.payudemo"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.firebase:firebase-common:20.0.0'
implementation 'com.payumoney.core:payumoney-sdk:7.4.4'
implementation 'com.payumoney.sdkui:plug-n-play:1.6.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
And it looks like :
I was trying to add some code in build.gradle(app) :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1'
classpath 'com.google.gms:google-services:4.3.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
but getting error.
I have wrote code before getting exact code or concept behind it after a lot of error handling.
In my system it works when modified in settings.gradle inside of repositories { } :
maven{ url("https://repo.gradle.org/gradle/libs-releases/") }
maven { url "https://jitpack.io" }
The complete settings.gradle file should have as given below :
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven{ url("https://repo.gradle.org/gradle/libs-releases/") }
maven { url "https://jitpack.io" }
}
}
rootProject.name = "PayU Demo"
include ':app'
I hope the above code helpful to you all guys.
It seems, that the dependency can not be loaded from JCenter. PayU mentioned in their [developer guide][1], that implementation("com.payumoney.sdkui:plug-n-play:<version>") is enough.
I recommend to remove the other payumoney dependencies and change your repository scope in the build.gradle to
repositories {
google()
mavenCentral()
maven{ url("https://repo.gradle.org/gradle/libs-releases/") }
maven { url "https://jitpack.io" }
}
``
[1]: https://developer.payumoney.com/android/
My app is not working after I updated my android phone to Android 10. So I migrated my app to androidx. Now I am trying to update my gradle from 2.3.1 to 3.5.1.
This is my build.gradle(Project:) file -
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
My build.gradle(Project:) file is -
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
defaultConfig {
applicationId "....."
minSdkVersion 19
targetSdkVersion 29
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
imlementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation files('....')
implementation files('....')
implementation files('....')
implementation files('....')
}
This is the Error I get -
ERROR: Gradle DSL method not found: 'imlementation()'
Possible causes:
The project '.....' may be using a version of the
Android Gradle plug-in that does not contain the method (e.g.
'testCompile' was added in 1.1.0). Upgrade plugin to version 3.5.1 and
sync project
The project '...' may be using a version of
Gradle that does not contain the method. Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin
I am new to android development. I am using android studio.
Thank you in advance.
You made a typo in your first implementation declaration. imlementation -> implementation.
Change imlementation
to
implementation
This question already has answers here:
Failed to resolve: com.android.support:cardview-v7:26.0.0 android
(26 answers)
Closed 5 years ago.
I have installed Android Studio 3 in my system and assigned a API level 26 version 1 & 2 both (Android Oreo (8.0) to the project as shown in the image below:
And the SDK tools as 26.1.1 version installed as shown in image below:
Code in app module gradle:
Troubleshooting steps i have tried so far:
changing the versions of appcompact-v7 in gradle file to (26.0.0,26.0.1,26.0.2,26.1.1,26.1.2) and sync.
Invalidate cache and restart.
Rebuild project.
I did not get success in above methods. I get the error messages as:
and in more details according to the respective versions I get error msg as:
But if I change the version as appcompact-v7:+ then it works fine and gradle sync is successful. I know that it is not a good practice to use the above method.
How can we resolve the above error. Or is there any way we can find out which version of appcompact the studio is downloading when we add reference as appcompact-v7:+ ?
I am new to Android Studio and Android development.
Since API 26, Google has moved the repository to Google() repo. You must add it in your build.gradle project file:
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and don't forget to update your gradle wrapper. You can use this command:
>gradle wrapper --gradle-version 4.2
Check ur build files. This is the best way to do it.
In your root level gradle.build use below
buildscript {
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and in your gradle-wrapper.properties file change the wrapper version as below
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
also in your app level build.gradle make sure you are using 26 vesion as below
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.xxxx"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
(Sry it would be better as a comment, but I can't)
If you are behind a proxy check your gradle.properties with proxy configuration
systemProp.http.proxyHost=[url/ip]
systemProp.http.proxyPort=[port]
systemProp.https.proxyHost=[url/ip]
systemProp.https.proxyPort=[port]
I'm trying to build a project with the ZXing library. I used the instructions in this post to integrate the library into my Android project and I believe I have done that successfully. However, when I try to build the entire project, there is an error in the Gradle build that refers to a dependency or something similar. However, I think I've already solved all the issues with dependencies.
The returned error in Gradle :
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:prepareDebugDependencies'.
The message is
Dependency QRR:android:unspecified on project app resolves to an APK archive which is not supported as a compilation dependency.
Here is the full Gradle log using Stacktrace.
EDIT:
In this project, I used the full ZXing library, not the Embedded or the Minimal.
After the download of the full repo of ZXing here, I've added the android folder as a new Module of the project. I've added the dependency on the Gradle file. Then, I've dowloaded the core on the Maven repo, then I imported it as JAR Library. I've added the dependency in the android:build-gradle.
The app:build.gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.mehdi.qrr"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile project(':android')
compile 'com.google.zxing:core:3.2.1'
}
repositories {
jcenter()
}
The Project:build-gradle is:
// 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
}
repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/journeyapps/maven"
}
}
The android:build-gradle (Gradle file of the ZXing project):
apply plugin: 'com.android.application'
android {
signingConfigs {
}
compileSdkVersion 21
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.google.zxing.client.android"
minSdkVersion 15
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.zxing:core:3.2.1'
}
I created Android App with some gradle dependencies. Now I want to create from this project *.jar (without resources and add them separately) file or *.aar file.
I tried to create new library project (with build.xml), copied my *.java and res files and run ant jar, I'm fixing problem one by one. Is there any better solution to do this?
You need to make two modules. The first module would be the jar. This should be POJOs (Plain Old Java Object) and nothing Android. The second module would be the aar. This could depend on your first project but add on the Android specific code / resources.
Then your project (MyApp) structure would look like this
MyApp/
MyApp/build.gradle
MyApp/settings.gradle
MyApp/PoJoProject/
MyApp/PoJoProject/build.gradle
MyApp/AndroidProject/
MyApp/AndroidProject/build.gradle
Then your settings.gradle file would look something like this:
include ':PoJoProject', ':AndroidProject'
Now in the modules
In MyApp/PoJoProject/build.gradle you will want to apply the java plugin. This module will build to the desired jar format that can be ran anywhere on the normal JVM.
plugins {
id 'java'
}
version '1.00'
group 'com.example.multimodule.gradle'
repositories {
jcenter()
}
dependencies {
compile 'com.google.code.gson:gson:2.5'
testCompile 'junit:junit:4.12'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
In the MyApp/AndroidProject/build.gradle you want to apply the android plugin. This module will build to the desired aar format and can only be used as an Android dependency.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}
}
apply plugin: 'com.android.application'
// version could be different from app version if needed
// `version` & `group` could also be in the top level build.gradle
version '1.00'
group 'com.example.multimodule.gradle'
repositories {
jcenter()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.multiproject.gradle.android"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
// let the android `aar` project use code from the `jar` project
compile project(':PoJoProject')
testCompile 'junit:junit:4.12'
}