Permalink
Browse files

Merge pull request #10 from johanlindquist/native-dependencies

Sample for transiently pulling in native dependencies
  • Loading branch information...
mosabua committed Oct 17, 2011
2 parents cde7ec4 + 944c96c commit 16086178fbeca4b83dd8a7892076ae914fe1935d
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.acme.hellojni"
+ android:versionCode="1"
+ android:versionName="1.0">
+ <uses-sdk android:minSdkVersion="3" />
+ <application android:label="@string/app_name"
+ android:debuggable="true">
+ <activity android:name="com.acme.hellojni.HelloTransientJni"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.jayway.maven.plugins.android.generation2.samples</groupId>
+ <artifactId>java-transient-dependency</artifactId>
+
+ <packaging>apk</packaging>
+ <name>Android Native Java Transient Dependency Sample</name>
+
+ <parent>
+ <groupId>com.jayway.maven.plugins.android.generation2.samples</groupId>
+ <artifactId>native-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>com.google.android</groupId>
+ <artifactId>android</artifactId>
+ <version>2.2.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Pull in the dependency on the jar which in turn depends on a native library -->
+ <dependency>
+ <groupId>com.jayway.maven.plugins.android.generation2.samples</groupId>
+ <artifactId>java-with-native-dependency</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.jayway.maven.plugins.android.generation2</groupId>
+ <artifactId>android-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <string name="app_name">HelloJni With Transient Native Dependency</string>
+</resources>
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.acme.hellojni;
+
+import android.app.Activity;
+import android.widget.TextView;
+import android.os.Bundle;
+
+public class HelloTransientJni extends Activity
+{
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ /* Create a TextView and set its content.
+ * the text is retrieved by calling a native
+ * function on a transiently included native library.
+ */
+ TextView tv = new TextView(this);
+ tv.setText( new HelloJni().stringFromJNI() );
+ setContentView(tv);
+ }
+
+}
@@ -54,7 +54,7 @@ public void onCreate(Bundle savedInstanceState)
*/
public native String unimplementedStringFromJNI();
- /* this is used to load the 'hello-jni' library on application
+ /* this is used to load the 'native-code' library on application
* startup. The library has already been unpacked into
* /data/data/com.acme.HelloJni/lib/libnative-code.so at
* installation time by the package manager.
View
@@ -13,6 +13,7 @@
<modules>
<module>java-with-native-dependency</module>
<module>java-with-native-library</module>
+ <module>java-transient-dependency</module>
<module>native-code</module>
<module>mixed-java-native-code</module>
</modules>

0 comments on commit 1608617

Please sign in to comment.