我正在android studio中使用NDK来完成我的新项目。我刚刚安装了NDK并在名为native-audio的NDK包中导入了一个示例项目。我尝试了几次来运行该项目,但它仍然返回
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 21
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.nativeaudio"
minSdkVersion.apiLevel 9
targetSdkVersion.apiLevel 9
buildConfigFields {
create() {
type "int"
name "VALUE"
value "1"
}
}
ndk {
moduleName "native-audio-jni"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles.add(file("proguard-rules.pro"))
}
}
// productFlavors {
// create("flavor1") {
// applicationId "com.example.nativeaudio"
// }
// }
// Configures source set directory.
sources {
main {
java {
source {
srcDir "src"
}
}
}
}
}
}
如果有人能弄清楚事情并解释实际上该代码会发生什么,那将对我有很大的帮助。我已经完成了StackOverflow中几乎所有可用的链接,但没有希望获得好处。
修改 应用程序/的build.gradle
// 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-experimental:0.6.0-alpha5'
}
}
allprojects {
repositories {
jcenter()
}
}
的build.gradle
def simulate1(theta):
# introduce evil random displacement
theta = theta + random.uniform(-noise, noise)
# apply stipid physics laws
f = math.sin(theta)
theta = theta + f*dt
return theta
#
# simulate evolution of the system during so many ticks
#
def simulate(theta, ticks):
thetas = []
for _ in range(ticks):
theta = simulate1(theta)
thetas.append(theta)
return thetas
我的项目结构是: