Closed xlisp closed 4 years ago
I have no idea why it doesn't work. It seems clojure's core is not AOT compiled, or not included in apk.
Does the sample project compiles and works for you? https://github.com/anolivetree/gradle-clojure-android-sample
Thanks for your reply. Yes, your project anolivetree/gradle-clojure-android-sample help me, but not success for this project https://github.com/chanshunli/termux-app .
➜ termux-app git:(master) find . -name build.gradle ./app/build.gradle ./build.gradle ./terminal-view/build.gradle ./terminal-emulator/build.gradle
➜ termux-app git:(master) cat settings.gradle include ':app', ':terminal-emulator', ':terminal-view'
* [DalvikDynamicClassLoader run in MyApp](https://github.com/chanshunli/termux-app/blob/master/app/src/main/java/com/termux/app/MyApp.java)
```java
// ➜ termux-app git:(master) cat ./app/src/main/java/com/termux/app/MyApp.java
package com.termux.app;
import android.app.Application;
import android.content.Context;
import android.util.Log;
import java.lang.reflect.Method;
import clojure.lang.IFn;
import clojure.lang.RT;
public class MyApp extends Application {
static public final String TAG = "clojure";
@Override
public void onCreate() {
super.onCreate();
try {
Class dalvikCLclass = Class.forName("clojure.lang.DalvikDynamicClassLoader");
Method setContext = dalvikCLclass.getMethod("setContext", Context.class);
setContext.invoke(null, this);
} catch (ClassNotFoundException e) {
Log.i(TAG, "DalvikDynamicClassLoader is not found, probably Skummet is used.");
} catch (Exception e) {
Log.e(TAG, "setContext method not found, check if your Clojure dependency is correct.");
}
}
}
I don't konw how to add "clojure aot task " for ./terminal-view/build.gradle & ./terminal-emulator/build.gradle
clojure {
aotCompile = true
}
cat ./terminal-view/build.gradle
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "com.github.dcendents.android-maven" version "2.0"
}
apply plugin: 'com.android.library'
ext {
bintrayName = 'terminal-view'
publishedGroupId = 'com.termux'
libraryName = 'TerminalView'
artifact = 'terminal-view'
libraryDescription = 'The terminal view used in Termux'
siteUrl = 'https://github.com/termux/termux'
gitUrl = 'https://github.com/termux/termux.git'
libraryVersion = '0.50'
}
android {
compileSdkVersion 27
dependencies {
implementation 'com.android.support:support-annotations:27.1.0'
api project(":terminal-emulator")
}
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
testImplementation 'junit:junit:4.12'
}
apply from: '../scripts/bintray-publish.gradle'
cat ./terminal-emulator/build.gradle
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "com.github.dcendents.android-maven" version "2.0"
}
apply plugin: 'com.android.library'
ext {
bintrayName = 'terminal-emulator'
publishedGroupId = 'com.termux'
libraryName = 'TerminalEmulator'
artifact = 'terminal-emulator'
libraryDescription = 'The terminal emulator used in Termux'
siteUrl = 'https://github.com/termux/termux'
gitUrl = 'https://github.com/termux/termux.git'
libraryVersion = '0.52'
}
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
externalNativeBuild {
ndkBuild {
cFlags "-std=c11", "-Wall", "-Wextra", "-Werror", "-Os", "-fno-stack-protector", "-Wl,--gc-sections"
}
}
ndk {
abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild {
path "src/main/jni/Android.mk"
}
}
}
tasks.withType(Test) {
testLogging {
events "started", "passed", "skipped", "failed"
}
}
dependencies {
testImplementation 'junit:junit:4.12'
}
apply from: '../scripts/bintray-publish.gradle'
Thanks for your help.
Hi, Hiroshi Sakurai,
I want run clojure in my Android clojure project, This is my project : https://github.com/chanshunli/termux-app .
but start error.
thanks :-)