[Android] Fixed JNI issues in libVLC & added 'test' option in compile.sh

Shivansh Saini git at videolan.org
Mon Dec 16 17:52:58 CET 2019


vlc-android | branch: master | Shivansh Saini <shivanshs9 at gmail.com> | Wed Aug 28 02:39:10 2019 +0530| [8e88e4bbc319caae83e3ebd8e99fd99dba1b76bf] | committer: Geoffrey Métais

Fixed JNI issues in libVLC & added 'test' option in compile.sh

Signed-off-by: Shivansh Saini <shivanshs9 at gmail.com>

> https://code.videolan.org/videolan/vlc-android/commit/8e88e4bbc319caae83e3ebd8e99fd99dba1b76bf
---

 compile.sh                                               | 14 ++++++++++++--
 libvlc/jni/libvlcjni.c                                   | 16 ++++++++--------
 .../androidTest/org/videolan/vlc/MultidexTestRunner.kt   | 12 ++++++++++++
 vlc-android/build.gradle                                 |  2 +-
 vlc-android/res/layout/activity_media_list_tv.xml        |  4 ----
 vlc-android/res/layout/activity_media_list_tv_item.xml   |  2 +-
 6 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/compile.sh b/compile.sh
index 0cc724b5c..24190c9bf 100755
--- a/compile.sh
+++ b/compile.sh
@@ -370,7 +370,9 @@ fi
 # Compile the UI #
 ##################
 BUILDTYPE="Dev"
-if [ "$SIGNED_RELEASE" = 1 ]; then
+if [ "$TEST" = 1 ]; then
+    BUILDTYPE="Debug"
+elif [ "$SIGNED_RELEASE" = 1 ]; then
     BUILDTYPE="signedRelease"
 elif [ "$RELEASE" = 1 ]; then
     BUILDTYPE="Release"
@@ -389,13 +391,21 @@ elif [ "$BUILD_MEDIALIB" = 1 ]; then
         GRADLE_ABI=$GRADLE_ABI ./gradlew -p medialibrary install bintrayUpload
     fi
 else
-    if [ "$RUN" = 1 ]; then
+    if [ "$TEST" = 1 -o "$RUN" = 1 ]; then
         ACTION="install"
     else
         ACTION="assemble"
     fi
     TARGET="${ACTION}${BUILDTYPE}"
     GRADLE_VLC_SRC_DIRS="$GRADLE_VLC_SRC_DIRS" CLI="" GRADLE_ABI=$GRADLE_ABI ./gradlew $TARGET
+
+    if [ "$TEST" = 1 ]; then
+        TARGET="vlc-android:install${BUILDTYPE}AndroidTest"
+        GRADLE_VLC_SRC_DIRS="$GRADLE_VLC_SRC_DIRS" CLI="" GRADLE_ABI=$GRADLE_ABI ./gradlew $TARGET
+
+        echo -e "\n===================================\nRun following for UI tests:"
+        echo "adb shell am instrument -w -e package org.videolan.vlc.gui org.videolan.vlc.debug.test/org.videolan.vlc.MultidexTestRunner 1> result_UI_test.txt"
+    fi
 fi
 
 #######
diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index fda2f8848..6e7c462cb 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -169,9 +169,9 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
     GET_CLASS(fields.Media.clazz,
               "org/videolan/libvlc/Media", true);
     GET_CLASS(fields.Media.Track.clazz,
-              "org/videolan/libvlc/Media$Track", true);
+              "org/videolan/libvlc/interfaces/IMedia$Track", true);
     GET_CLASS(fields.Media.Slave.clazz,
-              "org/videolan/libvlc/Media$Slave", true);
+              "org/videolan/libvlc/interfaces/IMedia$Slave", true);
     GET_CLASS(fields.MediaPlayer.clazz,
               "org/videolan/libvlc/MediaPlayer", true);
     GET_CLASS(fields.MediaPlayer.Title.clazz,
@@ -213,42 +213,42 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
            fields.Media.clazz,
            "createAudioTrackFromNative",
            "(Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;Ljava/lang/String;II)"
-           "Lorg/videolan/libvlc/Media$Track;");
+           "Lorg/videolan/libvlc/interfaces/IMedia$Track;");
 
     GET_ID(GetStaticMethodID,
            fields.Media.createVideoTrackFromNativeID,
            fields.Media.clazz,
            "createVideoTrackFromNative",
            "(Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;Ljava/lang/String;IIIIIIII)"
-           "Lorg/videolan/libvlc/Media$Track;");
+           "Lorg/videolan/libvlc/interfaces/IMedia$Track;");
 
     GET_ID(GetStaticMethodID,
            fields.Media.createSubtitleTrackFromNativeID,
            fields.Media.clazz,
            "createSubtitleTrackFromNative",
            "(Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)"
-           "Lorg/videolan/libvlc/Media$Track;");
+           "Lorg/videolan/libvlc/interfaces/IMedia$Track;");
 
     GET_ID(GetStaticMethodID,
            fields.Media.createUnknownTrackFromNativeID,
            fields.Media.clazz,
            "createUnknownTrackFromNative",
            "(Ljava/lang/String;Ljava/lang/String;IIIILjava/lang/String;Ljava/lang/String;)"
-           "Lorg/videolan/libvlc/Media$Track;");
+           "Lorg/videolan/libvlc/interfaces/IMedia$Track;");
 
     GET_ID(GetStaticMethodID,
            fields.Media.createSlaveFromNativeID,
            fields.Media.clazz,
            "createSlaveFromNative",
            "(IILjava/lang/String;)"
-           "Lorg/videolan/libvlc/Media$Slave;");
+           "Lorg/videolan/libvlc/interfaces/IMedia$Slave;");
 
     GET_ID(GetStaticMethodID,
            fields.Media.createStatsFromNativeID,
            fields.Media.clazz,
            "createStatsFromNative",
            "(IFIFIIIIIIIIIIF)"
-           "Lorg/videolan/libvlc/Media$Stats;");
+           "Lorg/videolan/libvlc/interfaces/IMedia$Stats;");
 
     GET_ID(GetStaticMethodID,
            fields.MediaPlayer.createTitleFromNativeID,
diff --git a/vlc-android/androidTest/org/videolan/vlc/MultidexTestRunner.kt b/vlc-android/androidTest/org/videolan/vlc/MultidexTestRunner.kt
new file mode 100644
index 000000000..7e3810fd2
--- /dev/null
+++ b/vlc-android/androidTest/org/videolan/vlc/MultidexTestRunner.kt
@@ -0,0 +1,12 @@
+package org.videolan.vlc
+
+import android.os.Bundle
+import androidx.multidex.MultiDex
+import androidx.test.runner.AndroidJUnitRunner
+
+class MultidexTestRunner: AndroidJUnitRunner() {
+    override fun onCreate(arguments: Bundle?) {
+        MultiDex.install(targetContext)
+        super.onCreate(arguments)
+    }
+}
diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index 7fd7d8669..efc994e04 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -57,7 +57,7 @@ android {
         resValue 'string', 'tv_provider_authority', "${applicationId}.tv"
         resValue 'string', 'moviepedia_api_url', getNextApiUrl(project)
 
-        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+        testInstrumentationRunner "org.videolan.vlc.MultidexTestRunner"
         // The following argument makes the Android Test Orchestrator run its
         // "pm clear" command after each test invocation. This command ensures
         // that the app's state is completely cleared between tests.
diff --git a/vlc-android/res/layout/activity_media_list_tv.xml b/vlc-android/res/layout/activity_media_list_tv.xml
index bda73a2c6..f6047e553 100644
--- a/vlc-android/res/layout/activity_media_list_tv.xml
+++ b/vlc-android/res/layout/activity_media_list_tv.xml
@@ -17,10 +17,6 @@
             name="item"
             type="MediaLibraryItem" />
 
-        <variable
-            name="cover"
-            type="android.graphics.drawable.BitmapDrawable" />
-
         <variable
             name="title"
             type="String" />
diff --git a/vlc-android/res/layout/activity_media_list_tv_item.xml b/vlc-android/res/layout/activity_media_list_tv_item.xml
index cfd868bec..785c6179f 100644
--- a/vlc-android/res/layout/activity_media_list_tv_item.xml
+++ b/vlc-android/res/layout/activity_media_list_tv_item.xml
@@ -40,7 +40,7 @@
 
 
         <ImageView
-            android:id="@+id/cover"
+            android:id="@+id/im_cover"
             android:layout_width="0dp"
             android:layout_height="48dp"
             android:background="@{cover}"



More information about the Android mailing list