I am trying to embed CrossWalk on native android using the method explained here:
embed crosswalk in android studio
The problem that I am having is that android studio is not building the needed libraries for ARM64, even though those libraries are on the Maven repository.
Here is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "my.app.id"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
}
flatDir{
dirs 'libs'
}
}
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:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'org.xwalk:xwalk_core_library:22.52.561.4'
compile (name: 'wikitudesdk', ext:'aar')
testCompile 'junit:junit:4.12'
}
Is there a way to tell android studio expicitly to compile those libraries?
OK I finally found the solution here:
diego.org
Basically if you need the ARM64 library you first need to download the correct library yourself:
curl -O https://download.01.org/crosswalk/releases/crosswalk/android/maven2/org/xwalk/xwalk_core_library/22.52.561.4/xwalk_core_library-22.52.561.4-arm64.aar
Then install it to the local maven repository:
mvn install:install-file -DgroupId=org.xwalk -DartifactId=xwalk_core_library \
-Dversion=22.52.561.4-arm64 -Dpackaging=aar \
-Dfile=xwalk_core_library-22.52.561.4-arm64.aar \
-DgeneratePom=true
And update you build gradle so that the repositories point to you local maven repo:
repositories {
mavenLocal()
}
and you compile the correct lib:
compile 'org.xwalk:xwalk_core_library:22.52.561.4-arm64'
Hope it helps someone as future reference.
Take a look at section Crosswalk AAR Version in https://crosswalk-project.org/documentation/android/embedding_crosswalk/crosswalk_aar.html:
Support different CPU architectures with each APK (such as for ARM, x86).
A product flavor defines a customized version of the application build by the project. We can have different flavors which generate apk for each architecture.
android {
...
productFlavors {
armv7 {
ndk {
abiFilters "armeabi-v7a", ""
}
}
x86 {
ndk {
abiFilters "x86", ""
}
}
}
}
Get the version code from the manifest. Add an extra digit to the end of the version code which implicity specifies the architecture. The x86 final digit is 4, arm is 2.
versionCode manifest.versionCode + 4
Build your project with Gradle, the following commands will build the corresponding arch apk in build/apk directory.
$ gradle assemblex86
$ gradle assemblearmv7
Use $ gradle build to build both arm and x86 APKs at once.
OpenCV uses these magic strings for arm64: digit 3 and abiFilter arm64-v8a (reference).
Related
So, the title pretty much sums up my problem. Anyone know how to fix it? Last time I build apk, it work fine on AS 2.X, but, I'm now developing with Kotlin so, I have to use AS 3.0.
I use AS 3.0 Canary 7 (This project is a fresh project)
This is my dummy class in my library (Stored in "domain".library.mylibrary)
class Test {
fun hello(): String {
return "hello"
}
}
And this is my (mylibrary) gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
minSdkVersion 19
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
testImplementation 'junit:junit:4.12'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" //Declared in project level gradle: ext.kotlin_version = '1.1.3-2'
}
My gradlew.bat clean build --info log: https://pastebin.com/bfTZ5s4e
Android Studio does not generate a jar by default, but rather an AAR file. If you want to get a jar output, you need to implement apply plugin: 'maven-publish' on top of your mylibrary/gradle.build file and read the following document: Chapter 36. Maven Publishing (new)
Another note, is that I would suggest you not to use ProGuard directly on your release artifact, but rather provide a consumer ProGuard file and let the users of your library to handle that task, otherwise they will have a hard time referencing obfuscated code. Read my answer on this here
While the build task may generate an output, it is known that the assemble task (or assembleRelease) is the one that will generate your aar output.
Try running the following command:
./gradlew clean assembleRelease
and check the output in /mylibrary/build/outputs/apk/release/ if I am not mistaken.
I suddenly started getting this error when trying to build. This was all working a few weeks ago with no changes that I know of. The issue seems to be related to react-native-fbsdk, but looking through its build.gradle it does not list support.appcompat-v7.25.x. Any advice?
A problem occurred configuring project ':app'.
> A problem occurred configuring project ':react-native-fbsdk'.
> Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugCompile'.
> Could not find com.android.support:appcompat-v7:25.3.1.
Searched in the following locations:
file:/Users/a/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom
file:/Users/a/.m2/repository/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar
https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.pom
https://jcenter.bintray.com/com/android/support/appcompat-v7/25.3.1/appcompat-v7-25.3.1.jar
build.gradle
apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "___"
minSdkVersion 16
targetSdkVersion 23
versionCode 22
versionName "1.5.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
manifestPlaceholders = [manifestApplicationId: "___",
onesignal_app_id: "___",
onesignal_google_project_number: "___"]
multiDexEnabled true
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
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"
signingConfig signingConfigs.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 {
compile project(':react-native-device-info')
compile project(':react-native-code-push')
compile project(':react-native-image-crop-picker')
compile project(':react-native-image-picker')
compile project(':react-native-fs')
compile project(':react-native-vector-icons')
compile project(':react-native-material-kit')
compile project(':react-native-config')
compile project(':react-native-onesignal')
compile project(':react-native-push-notification')
compile project(':react-native-android-permissions')
compile project(':react-native-android-keyboard-adjust')
compile project(':react-native-fbsdk')
compile (project(':react-native-fbads')) {
exclude group: 'com.google.android.gms'
}
compile 'com.facebook.android:audience-network-sdk:4.18.+'
compile 'com.google.ads.mediation:facebook:4.18.+'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile project(':react-native-billing')
compile project(':react-native-blur')
compile project(':instabug-reactnative')
compile project(':mobile-center-analytics')
compile project(':mobile-center-crashes')
compile (project(':react-native-appodeal')) {
exclude group: 'com.facebook.ads'
exclude (group: 'javax.inject', module: 'javax.inject')
}
compile project(':cheetah')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.facebook.fresco:animated-gif:0.12.0"
compile "com.android.support:multidex:1.0.1"
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
I've had the same problem (appcompat-v7:25.3.1), on an android project, but not using react.
I first tried to clean the gradle cache (~/.gradle/caches), like explained here, but it didn't help.
Then I looked at the SDK Manager.
Android Support libraries are normally installed via sdkmanager.
The libraries are then stored in a local maven repository : <SDK_HOME>/sdk/extras/android/m2repository/.
For example, for appcompat-v7 the list of versions installed is in <SDK_HOME>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/maven-metadata.xml.
So, for the Android Support Repository (revision: 47.0.0), the last version was normally 25.3.1.
To fix my problem, I had to uninstall the Android Support Repository via the SDK Manager, then reinstall it.
I also found another way to fetch support libraries : remotely.
After reading here (https://developer.android.com/topic/libraries/support-library/setup.html#add-library) and modifying <PROJECT_ROOT>/build.gradle like this :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Then I tried to use a newer version of appcompat-v7:25.4.0 that was not in my local maven repository, and it worked !
The list of this Google Maven repository's versions of this library can be seen there : https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/maven-metadata.xml.
Follow the steps,
Add google maven in project gradle (Project: build.gradle),
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Remove existing gradle cache with below command
rm -fr ~/.gradle/caches/
Have a clean build and run
My case was that this is react-native-fbsdk build.gradle (https://github.com/facebook/react-native-fbsdk/blob/master/android/build.gradle):
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 16
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.1.0'
compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
compile('com.facebook.android:facebook-android-sdk:4.+')
}
I am using React Native 0.37, so this is the line that broke for me:
compile('com.facebook.android:facebook-android-sdk:4.+')
Had to change to this for compatibility:
compile('com.facebook.android:facebook-android-sdk:4.18.+')
For this, try one of the following option:
1. Update your SDK manager > Go to build menu > clean project > then build project
or
2. Right click on project folder > open module setting > libraries > add com.android.support:appcompat-v7:25.3.1 > sync the project
3. Click on file menu > open project structure > and file the libraries
To solve this problem:
Open package.json and edit the react version to:
"react": "16.0.0-alpha.3",
"react-native": "0.43.1",
Delete node_modules directory
And re-install npm with the command npm install
In Addition: If you get a app:compileDebugJava ERROR, run react-native upgrade
(Got the solution from this github page and it worked for me)
Since gradle doesn't support declaring repositories on a per-artifact basis yet.
I modified my build.gradle (not app/build.gradle) to force all dependency to react-native to specific version:
allprojects {
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (details.requested.group == 'com.facebook.react' && details.requested.name == 'react-native') {
def file = new File("$rootDir/../node_modules/react-native/package.json")
def version = new groovy.json.JsonSlurper().parseText(file.text).version
details.useVersion version
}
}
}
}
}
This seems to be an issue with react-native itself.
There is no official fix for this (yet), however some people have reported upgrading to have solved their problem. You can check more details here
Update 1:
Hi #roachman, this is the exact error I got which pointed me to search for above. There is another ticket logged #14225 for same(cannot post link for some reason). I was just able to resolve it by including exact version of react-native version in build.gradle dependencies line compile "com.facebook.react:react-native:0.xx.y" instead of compile 'com.facebook.react:react-native:+' You might want to try that for all projects that use that setting or a more elegant settings suggested in above in issue #14223 by user david50407
Update 2
This is officially fixed now have a look https://github.com/facebook/react-native/issues/14225#issuecomment-305073392 (had to remove earlier link for issue 14223 as I cannot post more than 2 links)
If you upgraded react-native-fbsdk from 0.5 to 0.6 versions and have this issue then open your android project (pathToYourApp/android) in Android Studio and it automatically offers you to update dependencies. Now It should work fine!
I am very new to NDK debugging and I am trying to build the cpp code for debugging.
This is how my Application.mk file looks :
APP_STL := stlport_static
APP_MODULES := abc xyz
APP_CFLAGS += -fno-rtti -fexceptions
APP_ABI := armeabi armeabi-v7a
NDK_TOOLCHAIN := arm-linux-androideabi-4.9
and I an getting the following error , I have tried all the toolchains in ndk tools , what am I missing ?
update:
I realized that NDK_PROJECT_PATH is set to null , when built is run from Android studio. I am able to run
ndk-build -C from the terminal.
Actually my ultimate aim is to be able to debug native c++ files , by setting break points.
So current scenario:
I have native code in xyz folder with has jni folder containing android.mk and application.mk
I can run ndk-build in this folder and get the .so files, which I manually copy paste in jnilibs folder of the my android app (say appB):
This is the gradle of the appB :
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 13
targetSdkVersion 13
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//compile 'junit:junit:4.12'
// compile 'com.android.support:appcompat-v7:24.1.1'
}
Later I use this app as dependency in another app say appA.
This is the gradle of appA:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "*****"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories{
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:recyclerview-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:preference-v14:24.1.0'
compile project(':appB')
}
I need to be able to debug,
appA (which I can)
appB (which I can)
native code included as .so in appB (which I dont know yet how to)
aap
You can update the Android Studio to 2.2.2, and use the menu File-> Link C ++ Project with Gradle.
The official ndk samples can be found here!
There will be a local.properties files in your project folder from where the sdk & ndk paths can be configured. Normally the file has sdk directory path, you can configure your ndk path using keywork ndk.dir. For example
sdk.dir=YOUR_PATH_TO_SDK ( sdk.dir= /home/Android/Sdk)
ndk.dir=YOUR_PATH_TO_SDK ( ndk.dir= /home/Android/Sdk/ndk-bundle)
I received the Security Alert from Google Play regarding OpenSSL vulnerability. I do not use OpenSSL directly but one of the libraries that I am using could be.
I have updated everything including JDK, SDK, gradle, all possible libraries but still the OpenSSL version shows 1.0.1j for my app. I tried all the solutions mentioned in Stack Overflow, other websites and blogs but nothing changed. Given below are few links that I already referred:
Google Play and OpenSSL warning message
OpenSSL Security Alert Mail from Google Play for android apps
Update Android app to latest version of OpenSSL
Security Alert: You are using a highly vulnerable version of OpenSSL (Google Groups)
This is not a duplicate question because no answers of other questions could help me. Please help.
This is my app's build.gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.21.6'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
jcenter()
maven { url 'http://maven.localytics.com/public' }
maven() {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
lintOptions {
disable 'InvalidPackage'
abortOnError false
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
defaultConfig {
applicationId "co.myandroid.app"
minSdkVersion 14
targetSdkVersion 24
versionCode 29
versionName "1.0.0.19"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.6.0#aar') {
transitive = true;
}
compile('com.github.worker8:tourguide:1.0.17-SNAPSHOT#aar') {
transitive = true
}
compile project(':cropper')
compile 'com.android.support:support-v4:24.0.0'
compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.13.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:cardview-v7:24.0.0'
compile 'com.android.support:design:24.0.0'
compile 'com.squareup:android-times-square:1.6.5#aar'
compile 'com.google.android.gms:play-services-analytics:9.2.0'
compile 'com.google.android.gms:play-services-gcm:9.2.0'
compile 'com.google.android.gms:play-services-ads:9.2.0'
compile 'com.localytics.android:library:4.0.1'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
}
First you need to make sure where does that library come from. AFAIK you can't check this in Settings -> Project dependencies, at least not in the stable version.
But you can go to your Android Studio Terminal tab, make sure you are in the root of the project, and type this:
Windows version: gradlew app:dependencies
Mac/Linux version: ./gradlew app:dependencies
That will print a nice dependencies tree and hopefully you can find openssl there.
IMPORTANT: These commands will only work if you are using the gradle wrapper. If you are on Mac or Linux, you might need to chmod 755 first to make it executable. If not using the gradle wrapper, then I guess you might be able to do the same just changing to your gradle directory (if not in the global path) and replacing gradlew for gradle in the above posted commands.
I'm trying to set up Double Espresso, but that's probably not relevant here. What I'm trying to do is to set up a project in Android Studio using Gradle.
I'm very new to Gradle and build tools in general, though I've successfully used Maven before. Despite an hour of searching I can't find an answer to a very simple question.
In Jake Wharton's instructions it says
No more fumbling with local jars or dependency conflicts. Pull it in with one line:
androidTestCompile 'com.jakewharton.espresso:espresso:1.1-r3'
Pull in where? Where do I put/execute that command to import the project? In the command prompt? Do I put it in one of the scripts?
Thanks for any help.
You have a build.gradle file inside your app folder. In that file you can configure your project, "dependencies" and other options. It's very similar to maven. You have another build.gradle file in your root folder from your project. This conf file is more general and call the other build.gradle file.
e.g I have in one of my projects
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.acostela.example"
minSdkVersion 17
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:20.+'
compile "com.android.support:gridlayout-v7:18.0.+"
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
compile 'commons-net:commons-net:3.3'
compile 'net.sf.opencsv:opencsv:2.3'
}
Dependencies here are similar to maven and the use in that tool of "/".
Gradle take libs from repositories in the same way of maven. In fact you can use the maven repository. You have a tab with the gradle sentence to download libraries.
http://mvnrepository.com/artifact/com.squareup.assertj/assertj-android/1.0.0