Skip to content

Commit 41cf420

Browse files
committed
Add Chaquopy to Android template
1 parent 4948dd5 commit 41cf420

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

apps/android_pythonnative_3/app/src/main/java/com/pythonnative/pythonnative/MainActivity.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ class MainActivity : AppCompatActivity() {
3636
// val pyButton = createButtonModule.callAttr("create_button", this).toJava(Button::class.java)
3737
// layoutMain.addView(pyButton)
3838

39-
// val createWidgetsModule = py.getModule("create_widgets")
40-
// val pyLayout = createWidgetsModule.callAttr("create_widgets", this).toJava(LinearLayout::class.java)
41-
// layoutMain.addView(pyLayout)
39+
val createWidgetsModule = py.getModule("create_widgets")
40+
val pyLayout = createWidgetsModule.callAttr("create_widgets", this).toJava(LinearLayout::class.java)
41+
layoutMain.addView(pyLayout)
4242

4343
// val createConstraintLayoutModule = py.getModule("create_constraint_layout")
4444
// val pyLayout = createConstraintLayoutModule.callAttr("create_constraint_layout", this).toJava(ConstraintLayout::class.java)
4545
// layoutMain.addView(pyLayout)
4646

47-
val createRecyclerViewModule = py.getModule("create_recycler_view")
48-
val pyRecyclerView = createRecyclerViewModule.callAttr("create_recycler_view", this).toJava(RecyclerView::class.java)
49-
layoutMain.addView(pyRecyclerView)
47+
// val createRecyclerViewModule = py.getModule("create_recycler_view")
48+
// val pyRecyclerView = createRecyclerViewModule.callAttr("create_recycler_view", this).toJava(RecyclerView::class.java)
49+
// layoutMain.addView(pyRecyclerView)
5050

5151
// Existing code for displaying plot
5252
// val imageView = findViewById<ImageView>(R.id.image_home)

apps/templates/android_template/app/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'com.android.application'
33
id 'org.jetbrains.kotlin.android'
4+
id 'com.chaquo.python'
45
}
56

67
android {
@@ -15,6 +16,20 @@ android {
1516
versionName "1.0"
1617

1718
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19+
ndk {
20+
abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
21+
}
22+
python {
23+
version "3.8"
24+
pip {
25+
install "matplotlib"
26+
install "pythonnative"
27+
28+
// "-r"` followed by a requirements filename, relative to the
29+
// project directory:
30+
// install "-r", "requirements.txt"
31+
}
32+
}
1833
}
1934

2035
buildTypes {

apps/templates/android_template/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ plugins {
33
id 'com.android.application' version '8.0.2' apply false
44
id 'com.android.library' version '8.0.2' apply false
55
id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
6+
id 'com.chaquo.python' version '14.0.2' apply false
67
}

0 commit comments

Comments
 (0)