I want to play two videos on a screen.But when I play one video the other video get stopped. Anyone knows how can I solve this problem?
In my gradle,
implementation 'cn.jzvd:jiaozivideoplayer:7.7.0'
In my XML,
<cn.jzvd.JzvdStd
android:id="#+id/jzVideo"
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<cn.jzvd.JzvdStd
android:id="#+id/jzVideo2"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="5dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="#id/jzVideo"/>
in my activty,
JzvdStd jzvdStd = findViewById(R.id.jzVideo);
JzvdStd jzvdStd2 =findViewById(R.id.jzVideo2);
and setUp link after initialization.
in my proguard-rules.pro
-keep public class cn.jzvd.JZMediaSystem {*; }
-keep public class cn.jzvd.demo.CustomMedia.CustomMedia {*; }
-keep public class cn.jzvd.demo.CustomMedia.JZMediaIjk {*; }
-keep public class cn.jzvd.demo.CustomMedia.JZMediaSystemAssertFolder {*; }
-keep class tv.danmaku.ijk.media.player.** {*; }
-dontwarn tv.danmaku.ijk.media.player.*
-keep interface tv.danmaku.ijk.media.player.** { *; }
Related
My app crashes when I run my app after minifyEnabled true.
The error I am getting after running the app is this
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.instant/com.example.instant.activity.IntroActivity}: android.view.InflateException: Binary XML file line #56 in com.example.instant:layout/activity_intro: Binary XML file line #56 in com.example.instant:layout/activity_intro: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3304)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3443)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2040)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:224)
at android.app.ActivityThread.main(ActivityThread.java:7520)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: android.view.InflateException: Binary XML file line #56 in com.example.instant:layout/activity_intro: Binary XML file line #56 in com.example.instant:layout/activity_intro: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #56 in com.example.instant:layout/activity_intro: Error inflating class com.google.android.material.bottomnavigation.BottomNavigationView
This is my progaurd file
-keep class com.google.gson.** { *; }
-keep class com.smsdaakindia.instantpay.utils.** { *; }
-keep class com.smsdaakindia.instantpay.model.** { *; }
-keep class com.google.android.material.** { *; }
#-dontwarn com.google.android.material.**
#Material design
#-dontnote com.google.android.material.**
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
-dontwarn com.google.android.material.**
-dontnote com.google.android.material.**
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
# RETRO LAMBDA
-dontwarn java.lang.invoke.*
# RETROFIT RULES
-keep class com.squareup.** { *; }
-keep interface com.squareup.** { *; }
-dontwarn com.squareup.okhttp.**
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {#retrofit.http.* <methods>;}
-keep interface retrofit.** { *;}
-keep interface com.squareup.** { *; }
-dontwarn rx.**
-dontwarn retrofit.**
-keep class com.google.gson.* { *; }
-keep class com.google.inject.* { *; }
-keep class org.apache.http.* { *; }
-keep class org.apache.james.mime4j.* { *; }
-keep class javax.inject.* { *; }
-keep class retrofit.* { *; }
-keepattributes Signature
-keepattributes *Annotation*
-keepattributes EnclosingMethod
This is my dependencyimplementation 'com.google.android.material:material:1.0.0
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="bottomNavigationHandler"
type="com.example.instant.viewmodel.BottomNavigationHandler" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:fitsSystemWindows="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/navigationParent"
android:orientation="vertical">
<FrameLayout
android:id="#+id/main_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<LinearLayout
android:id="#+id/navigationParent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:orientation="vertical">
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="0.01dp"
android:layout_above="#+id/navigation"
android:background="#color/grey_100"
android:elevation="1dp" />
<!-- <include-->
<!-- layout="#layout/bottom_bar"-->
<!-- android:id="#+id/bottom" />-->
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:showAsAction="always|withText"
app:labelVisibilityMode="labeled"
app:itemTextColor="#drawable/bottom_view"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="#menu/bottom_nav_items"
android:background="#color/white"
app:onNavigationItemSelected="#{bottomNavigationHandler::onNavigationClick}"
app:elevation="0dp"/>
<!-- <com.google.android.material.bottomnavigation.BottomNavigationView-->
<!-- android:id="#+id/navigation"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="52dp"-->
<!-- android:background="#color/lightgrey"-->
<!-- android:visibility="visible"-->
<!-- android:showAsAction="always|withText"-->
<!-- app:itemBackground="#color/lightlightgrey"-->
<!-- app:itemIconTint="#drawable/bottom_view"-->
<!-- app:itemTextAppearance="#style/TextStyleBNV"-->
<!-- app:itemTextColor="#drawable/bottom_view"-->
<!-- app:labelVisibilityMode="labeled"-->
<!-- app:menu="#menu/bottom_nav_items"-->
<!-- app:onNavigationItemSelected="#{bottomNavigationHandler::onNavigationClick}" />-->
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
In my app I use a custom image view from exetrnal jar library. And if I enable proguard, I get exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{eu.example.testapp/eu.example.testapp.ui.activities.DetailsActivity_}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Binary XML file line #0: Error inflating class fr.idapps.image.IDAppsImageView
in the proguard-android.txt I tried to put:
-keep class fr.idapps.** { *; }
-keep class fr.idapps.image.** { *; }
-keep public class * extends android.widget.ImageView
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
but nothing helps. I also tried to move this class from the library to my code. Even in this case I got the same error.
Here is the place where this class is inflated:
<eu.example.testapp.ui.views.LocationItem xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/item_background"
android:orientation="vertical"
android:paddingBottom="#dimen/margin_medium" >
<!-- Header -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#color/light_anthracite"
android:padding="#dimen/margin_small"
android:layout_marginBottom="#dimen/margin_medium" >
<ImageView
android:id="#+id/view_location_item_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:src="#drawable/ic_detail_location" />
<TextView
android:id="#+id/view_location_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/view_detail_item_title_location"
android:paddingLeft="#dimen/margin_medium" />
</LinearLayout>
<fr.idapps.image.IDAppsImageView
android:id="#+id/view_location_item_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/margin_medium"
android:paddingRight="#dimen/margin_medium"
app:imageRatio="preserve" />
</eu.example.testapp.ui.views.LocationItem>
EDIT: I use the last gradle version and enable proguard in this way:
buildTypes {
release {
minifyEnabled true // enables/disables proguard
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "Test-v${variant.versionName}-v${variant.versionCode}.apk"
}
}
}
}
So you need to add your custom class (which having in your package) into proguard-project.txt :-
-keep public class com.abc.xyz
and unable to see that your not include eu.example.testapp.ui.views.LocationItem
I have inserted code AdMob ads, but it does not show on my phone (I do not run on the shirt). I have not published app on the store.
In AndroidManifest file
Code in layout file:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/gameover"
android:orientation="vertical"
android:paddingLeft="7dp"
android:paddingRight="7dp"
android:background="#color/bgend" >
<Button
android:id="#+id/btnBackhome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/yourBest"
android:layout_marginBottom="80dp"
android:layout_marginRight="48dp"
android:background="#drawable/rate" />
<Button
android:id="#+id/btnReplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/btnBackhome"
android:layout_alignLeft="#+id/yourBest"
android:layout_marginLeft="34dp"
android:background="#drawable/play" />
<TextView
android:id="#+id/yourBest"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/yourMove"
android:layout_alignTop="#+id/yourMove"
android:layout_marginTop="39dp"
android:gravity="center"
android:text="Best: "
android:textColor="#android:color/white"
android:textSize="18dp"
android:textStyle="bold" />
<TextView
android:id="#+id/yourMove"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/Replay"
android:layout_alignParentRight="true"
android:layout_marginBottom="74dp"
android:gravity="center"
android:text="New: "
android:textColor="#android:color/white"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/Best"
android:layout_alignLeft="#+id/Move"
android:layout_marginBottom="14dp"
android:gravity="center"
android:text="Game Over"
android:textColor="#android:color/white"
android:textSize="30sp"
android:textStyle="bold" />
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-........"
/>
</RelativeLayout>
Code gameover.java. I removed the command line to test the virtual machine
package com.vudinh.eastmath;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class GameOverActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.game_over);
// TODO Auto-generated constructor stub
AdView adView = (AdView) this.findViewById(R.id.adView);
//request TEST ads to avoid being disabled for clicking your own ads
AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)// This is for emulators
// .addTestDevice("2EAB96D84FE62876379A9C030AA6A0AC")
.build();
adView.loadAd(adRequest);
}
}
Proguard file:
-dontwarn **CompatHoneycomb
-keep class android.support.v4.** { *; }
-dontwarn android.support.v4.**
-dontskipnonpubliclibraryclassmembers
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep class com.startapp.** {
*;
}
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile,
LineNumberTable, *Annotation*, EnclosingMethod
-dontwarn android.webkit.JavascriptInterface
-dontwarn com.startapp.**
-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembers class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
There doesn't appear to be anything wrong with your code.
Have a look at your log, you should see there the ad request and response.
If there are no ads to show, you will see that in the logs, but nothing will be display on the screen.
The problem occurs only when built with proguard + gradle. If exported from android tools and proguard - all references are mapped correctly.
Problem:
I have defined some id's in a library project
<resources>
<item type="id" name="background" />
</resources>
And the activity layout is in main project
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/splash"
tools:ignore="ContentDescription" />
The NullPointer after being built with proguard is thrown at main project's Activity
this.findViewById(R.id.background).setOnClickListener(new View.OnClickListener() {
Don't suggest me redefining id's because it's a wrong approach and crashes anyway.
android:id="#+id/background"
UPDATE: it turns out it messes even id's defined in layout of main project like
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/backgroundTEST"/>
Also crashes with NullPointerException.I thought it was because of library project because the very first one that fails was one from a library project.
The configuration is as follows
The $ANDROID_HOME/tools/proguard/proguard-android.txt is
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-dontwarn android.support.**
The proguard-project.txt for my project
-injars bin/classes
-injars libs
-outjars bin/classes-processed.jar
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.support.v4.app.FragmentActivity
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
From build.gradle
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android.txt')
proguardFile 'proguard-project.txt'
signingConfig signingConfigs.release
}
}
My concern was, maybe it does not include getDefaultProguardFile('proguard-android.txt').
Well, for an experiment I've copy-pasted proguard-android.txt contents to proguard-project.txt And still after
gradle clean
gradle assembleRelease
it crashed.
I have that in my Proguard config to cater for R class
-keepclassmembers class **.R$* {
public static <fields>;
}
Try adding the following as well:
-keepclasseswithmembernames class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
I am using an Ant script to generate my APK's with Proguard. If I manually build my APKs using the Eclipse export feature, everything works fine, but if I use my Ant script, I'm getting a "could not find call 'com.google.ads.Adview'" exception thrown to the log with a Force Close.
This is my proguard.cfg file, where I'm telling it to keep com.google.ads:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-libraryjars C:\Workspace\JARs\CWAC-WakefulIntentService-0.4.5.jar;C:\Workspace\JARs\GoogleAdMobAdsSdk-6.0.0.jar;C:\Workspace\JARs\android-support-v4.jar
-repackageclasses ''
-allowaccessmodification
-optimizations !code/simplification/arithmetic
-keepattributes *Annotation*
-dontwarn **CompatHoneycomb
-dontwarn **CompatHoneycombMR2
-dontwarn **CompatCreatorHoneycombMR2
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.Fragment
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keep public class com.google.ads.** { *; }
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
public void set*(...);
}
# This will avoid all the onClick listeners referenced from XML Layouts from being removed
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * implements android.os.Parcelable {
static android.os.Parcelable$Creator CREATOR;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-dontwarn android.support.**
This is my build.xml file, where I'm building the APK, then copying it to a directory.
<?xml version="1.0" encoding="UTF-8"?>
<project name="master" default="build">
<target name="build">
<ant dir="../Project" antfile="build.xml" inheritAll="false" inheritRefs="false" target="release" />
<copy todir="../APKs">
<fileset dir="../Project/bin" includes="*release.apk" />
</copy>
</target>
</project>
UPDATE:
After tinkering with this more, I'm thinking this issue has nothing to do with Proguard, but something with the Ant script and the external jars.
make sure you have your jars in a libs directory for your project. With eclipse you can put them in other folders and then just set your build environment. However ant expects them in your libs folder.