Skip to content

Commit

Permalink
try ndk build in android studio
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin He committed Apr 1, 2016
1 parent b3e0fa3 commit a053f05
Show file tree
Hide file tree
Showing 513 changed files with 124,563 additions and 84 deletions.
89 changes: 63 additions & 26 deletions demo/amr/amr.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":amr" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="io.kvh" external.system.module.version="1.0.1" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":amr" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="demo" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand All @@ -8,46 +8,80 @@
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="SELECTED_BUILD_VARIANT" value="armDebug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="ASSEMBLE_TASK_NAME" value="assembleArmDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileArmDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
<task>generateArmDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
<option name="LIBRARY_PROJECT" value="true" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/arm/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/arm/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/arm/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/arm/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/arm/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/arm/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/arm/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/arm/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/armDebug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/armDebug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/armDebug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/armDebug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/armDebug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/armDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/armDebug/renderscript" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testArmDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testArmDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testArmDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testArmDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testArmDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testArmDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testArmDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/arm/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/arm/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/arm/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/arm/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/arm/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/arm/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/arm/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/arm/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/arm/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/arm/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/arm/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/arm/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/arm/renderscript" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestArm/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestArm/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestArm/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestArm/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestArm/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestArm/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestArm/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testArm/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testArm/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testArm/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testArm/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testArm/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testArm/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testArm/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/renderscript" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
Expand All @@ -61,29 +95,32 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/renderscript" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/renderscript" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/renderscript" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/mockable-android-19.jar" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/objectFiles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
Expand All @@ -94,7 +131,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/test-results" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
82 changes: 63 additions & 19 deletions demo/amr/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,69 @@
apply plugin: 'com.android.library'
apply plugin: "com.android.model.application"

android {
compileSdkVersion 19
buildToolsVersion '19.1.0'

sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle-experimental:0.7.0-alpha4"

defaultConfig {
minSdkVersion 9
targetSdkVersion 19
versionCode 1
versionName "1.0"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

sources {
main {
jni {
source {
srcDirs 'src/main/jni'
}
}
}
}

ndk {
moduleName "amr-codec"
cppFlags.addAll([
"-I${file("src/main/jni/oscl")}".toString(),
"-I${file("src/main/jni/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/include")}".toString(),
"-I${file("src/main/jni/opencore/codecs_v2/audio/gsm_amr/amr_nb/common/src")}".toString(),
"-I${file("src/main/jni/opencore/codecs_v2/audio/gsm_amr/amr_nb/dec/include")}".toString(),
"-I${file("src/main/jni/opencore/codecs_v2/audio/gsm_amr/amr_nb/dec/src")}".toString(),
"-I${file("src/main/jni/opencore/codecs_v2/audio/gsm_amr/amr_nb/enc/include")}".toString(),
"-I${file("src/main/jni/opencore/codecs_v2/audio/gsm_amr/amr_nb/enc/src")}".toString(),
"-I${file("src/main/jni/opencore/codecs_v2/audio/gsm_amr/common/dec/include")}".toString(),
"-I${file("src/main/jni")}".toString()
])

}

productFlavors {
create("arm") {
ndk {
abiFilters.add("armeabi-v7a")
}
}
}

defaultConfig {
applicationId "io.kvh.media"
minSdkVersion.apiLevel 15
targetSdkVersion.apiLevel 22
versionCode 1
versionName "1.0"
}

buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
}
}
}
Expand All @@ -28,4 +72,4 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}

apply from:'./bintray.gradle'
//apply from: './bintray.gradle'
Binary file removed demo/amr/libs/armeabi-v7a/libamr-codec.so
Binary file not shown.
Binary file removed demo/amr/libs/armeabi/libamr-codec.so
Binary file not shown.
17 changes: 0 additions & 17 deletions demo/amr/src/main/java/com/hikvh/media/amr/AmrDecoder.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hikvh.media;
package io.kvh.media;

import android.content.Context;
import android.content.pm.PackageManager;
Expand Down
17 changes: 17 additions & 0 deletions demo/amr/src/main/java/io/kvh/media/amr/AmrDecoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.kvh.media.amr;

/**
* Created by kv.h on 14/11/21.
*/
public class AmrDecoder {

public static native long init();

public static native void exit(long state);

public static native void decode(long state, byte[] in, short[] out);

static {
System.loadLibrary("amr-codec");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hikvh.media.amr;
package io.kvh.media.amr;

/**
* Created by kv.h on 14/11/21.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.hikvh.media.sound;
package io.kvh.media.sound;

import android.util.Log;

import com.hikvh.media.amr.AmrEncoder;
import io.kvh.media.amr.AmrEncoder;

import java.util.Collections;
import java.util.LinkedList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.hikvh.media.sound;
package io.kvh.media.sound;

import android.util.Log;

import com.hikvh.media.KCacheUtils;
import io.kvh.media.KCacheUtils;

import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hikvh.media.sound;
package io.kvh.media.sound;

import android.media.AudioFormat;
import android.media.AudioRecord;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.hikvh.media.sound;
package io.kvh.media.sound;

import android.os.Handler;
import android.util.Log;

import com.hikvh.media.amr.AmrDecoder;
import io.kvh.media.amr.AmrDecoder;

/**
* Created by changbinhe on 14/11/22.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hikvh.media.sound;
package io.kvh.media.sound;

import java.io.File;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hikvh.media.sound;
package io.kvh.media.sound;

import android.util.Log;

Expand Down
35 changes: 35 additions & 0 deletions demo/amr/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

PV_TOP := $(LOCAL_PATH)/opencore
PV_INCLUDES := $(LOCAL_PATH)/oscl \
$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/include \
$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/src \
$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/include \
$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/src \
$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/include \
$(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/src \
$(PV_TOP)/codecs_v2/audio/gsm_amr/common/dec/include

include $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/common/Android.mk
include $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/dec/Android.mk
include $(PV_TOP)/codecs_v2/audio/gsm_amr/amr_nb/enc/Android.mk

include $(CLEAR_VARS)

LOCAL_PATH := $(PV_TOP)/..
LOCAL_MODULE := amr-codec
LOCAL_SRC_FILES := $(LOCAL_PATH)/amr_encoder.cpp \
$(LOCAL_PATH)/amr_decoder.cpp \
$(LOCAL_PATH)/wrapper.cpp

LOCAL_C_INCLUDES := $(PV_INCLUDES)


LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog
LOCAL_SHARED_LIBRARIES := libpv_amr_nb_common_lib \
libpvencoder_gsmamr \
libpvdecoder_gsmamr


include $(BUILD_SHARED_LIBRARY)
4 changes: 4 additions & 0 deletions demo/amr/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
APP_ABI := all
APP_MODULES := amr-codec
APP_PLATFORM := android-16
APP_OPTM := release
Loading

0 comments on commit a053f05

Please sign in to comment.