When trying to load a url in my Android Things webview the page initially loads, then crashes the UI with an error message pointing towards the IoT FrameworkPackageStubs.
I am using a Raspberry Pi on Dev Preview 5.1 which supports Webviews and OpenGL but have no idea why my very simple application seems to be crashing. The code for it is as follows
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView) findViewById(R.id.webView);
if(webView != null)
webView.loadUrl("https://www.facebook.com");
}
Here is my manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.airborneathletics.videohwtest">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<uses-library android:name="com.google.android.things" android:required="false"/>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
and my Gradle depdencies
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
provided 'com.google.android.things:androidthings:0.5.1-devpreview'
}
And finally my error message I'm receiving when making the calls.
--------- beginning of crash
08-31 20:30:33.458 10146-10146/com.google.android.iot.frameworkpackagestubs E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.android.iot.frameworkpackagestubs, PID: 10146
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.google.android.iot.frameworkpackagestubs/com.google.android.iot.frameworkpackagestubs.Stubs$BrowserStub}: java.lang.ClassNotFoundException: Didn't find class "com.google.android.iot.frameworkpackagestubs.Stubs$BrowserStub" on path: DexPathList[[zip file "/system/app/IoTFrameworkPackageStubs/IoTFrameworkPackageStubs.apk"],nativeLibraryDirectories=[/system/app/IoTFrameworkPackageStubs/lib/arm, /system/lib, /system/vendor/lib, /system/lib, /system/vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2718)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.iot.frameworkpackagestubs.Stubs$BrowserStub" on path: DexPathList[[zip file "/system/app/IoTFrameworkPackageStubs/IoTFrameworkPackageStubs.apk"],nativeLibraryDirectories=[/system/app/IoTFrameworkPackageStubs/lib/arm, /system/lib, /system/vendor/lib, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1173)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2708)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
I will admit some websites do work, but when I go to https://www.google.com and type in a search it crashes with the same message.
Thanks for the assistance.
You're likely running into the same problem as here.
When links are loaded in Android, by default the system will try to launch an application to handle the URL, in this case a browser. However Android Things does not include a browser by default, so it fails to handle the URL and crashes.
You can override this default behavior and have the URLs load in your app's WebView, by setting the WebViewClient in your app before loading any URLs:
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient());
This is documented here.
If you have a web view along with a progress bar, then the code is down below:
WebView myWebView = (WebView) findViewById(R.id.webView3);
progressDialog = new ProgressDialog(YOUR_ACTIVITY.this);
progressDialog.setCancelable(true);
progressDialog.setMessage("Please wait....");
progressDialog.show();
myWebView.setWebViewClient(new WebViewClient() { // setting Progress Bar
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
Log.d(TAG, "LOADING");
return true;
}
#Override
public void onPageFinished(WebView view, String url) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
});
myWebView.setInitialScale(1);
myWebView.getSettings().setLoadWithOverviewMode(true);
myWebView.getSettings().setUseWideViewPort(true);
myWebView.getSettings().setJavaScriptEnabled(true);myWebView.loadUrl("https://www.google.com");
myWebView.getSettings().setSupportZoom(true);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.getSettings().setDisplayZoomControls(false);
Related
So I am currently trying to import multidex into my project, I have followed the provided documentations/QnA
Android Application using Firebase database keeps crashing when launching?
https://developer.android.com/studio/build/multidex#java
and have done the following amends to my build.gradle app file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.finalyearprojectapp"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
multiDexKeepFile file('multidex-config.txt')
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation "androidx.multidex:multidex:2.0.1"
//implementation 'com.android.support:multidex:1.0.3'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-firestore:22.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
I have followed the documentation until it has mentioned that I am needed to implement the following code into my android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="androidx.multidex.MultiDexApplication" >
...
</application>
</manifest>
I have added this to the manifest, my XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.finalyearprojectapp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="androidx.multidex.MultiDexApplication" >
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainScreen" />
<activity android:name=".RegisterActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
But now I run across this error
Failed to parse XML in C:\Users\jabze\Desktop\FinalApp\app\src\main\AndroidManifest.xml
ParseError at [row,col]:[11,43]
Message: expected start or end tag
Affected Modules: app
I have done literally every tutorial out there and I just cannot figure out the issue, i feel like giving up on this project.
I have tried extending it from each class as mentioned in documentation and all my code has errors to resolve, some with no context.
I have tried extending it using a base class which uses multidex and then trying to add it into the android manifest like this,
android:name=".BaseApp"
Then creating a class to extend from multidex
import androidx.multidex.MultiDexApplication;
public class BaseApp extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
}
}
This has solved the configuration problem, but now i recieve a error when trying to open my app, logcat
2021-03-29 00:28:45.035 31916-31916/? I/lyearprojectap: Not late-enabling -Xcheck:jni (already on)
2021-03-29 00:28:45.054 31916-31916/? I/lyearprojectap: Unquickening 12 vdex files!
2021-03-29 00:28:45.055 31916-31916/? W/lyearprojectap: Unexpected CPU variant for X86 using defaults: x86
2021-03-29 00:28:45.150 31916-31916/com.example.finalyearprojectapp D/ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.test.base.jar
2021-03-29 00:28:45.395 31916-31916/com.example.finalyearprojectapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2021-03-29 00:28:45.395 31916-31916/com.example.finalyearprojectapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2021-03-29 00:28:45.398 31916-31916/com.example.finalyearprojectapp I/MultiDex: VM with version 2.1.0 has multidex support
2021-03-29 00:28:45.398 31916-31916/com.example.finalyearprojectapp I/MultiDex: Installing application
2021-03-29 00:28:45.399 31916-31916/com.example.finalyearprojectapp I/MultiDex: VM has multidex support, MultiDex support library is disabled.
2021-03-29 00:28:45.419 31916-31916/com.example.finalyearprojectapp W/ComponentDiscovery: Class com.google.firebase.dynamicloading.DynamicLoadingRegistrar is not an found.
2021-03-29 00:28:45.435 31916-31916/com.example.finalyearprojectapp I/FirebaseApp: Device unlocked: initializing all Firebase APIs for app [DEFAULT]
2021-03-29 00:28:45.529 31916-31977/com.example.finalyearprojectapp W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-03-29 00:28:45.564 31916-31916/com.example.finalyearprojectapp D/FirebaseAuth: Notifying id token listeners about user ( v9NWiRcvjMTz4y8V8kXy6f7RZdQ2 ).
2021-03-29 00:28:45.566 31916-31916/com.example.finalyearprojectapp D/AndroidRuntime: Shutting down VM
2021-03-29 00:28:45.567 31916-31916/com.example.finalyearprojectapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.finalyearprojectapp, PID: 31916
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp$IdTokenListenersCountChangedListener;
at com.google.firebase.auth.zzp.create(Unknown Source:3)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0(ComponentRuntime.java:132)
at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(Unknown Source:4)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:291)
at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:281)
at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:584)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:303)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:7239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.FirebaseApp$IdTokenListenersCountChangedListener" on path: DexPathList[[zip file "/data/app/~~yUZ3UTW9uE5Wv9gw7MBIVA==/com.example.finalyearprojectapp-ZqPMbXUiTbtxIQSglqq2dg==/base.apk"],nativeLibraryDirectories=[/data/app/~~yUZ3UTW9uE5Wv9gw7MBIVA==/com.example.finalyearprojectapp-ZqPMbXUiTbtxIQSglqq2dg==/lib/x86, /system/lib, /system_ext/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.firebase.auth.zzp.create(Unknown Source:3)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0(ComponentRuntime.java:132)
at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(Unknown Source:4)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:291)
at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:281)
at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:584)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:303)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:7239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2021-03-29 00:28:45.654 31916-31979/com.example.finalyearprojectapp W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-03-29 00:28:45.667 31916-31979/com.example.finalyearprojectapp I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
2021-03-29 00:28:45.667 31916-31979/com.example.finalyearprojectapp I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
You want to create a Base class that extends the MultiDex if you don't have one.
public class BaseApp extends MultiDexApplication {
#Override
public void onCreate() {
super.onCreate();
}
}
Your Manifest can look like below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.finalyearprojectapp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".BaseApp"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainScreen" />
<activity android:name=".RegisterActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Edit:
You should upgrade your firebase to the latest, or at least version from 17.0.0 and above.
I was told that According to firebase release notes May 07, 2019, it says; "If you use Firebase Authentication, update to firebase-auth v17.0.0 or later to ensure functionality alignment with other updated Firebase libraries."
Hello my dear friends,
I am trying to develop media files to my server with the help of Retrofit and a Fileprovider.
Like the title already describes my situation, am I looking for a solution of the following error. This error let the app crash during the launch while the app runs without issues on other phones. I am trying for a week now to fix this error and tried everything from Multidex integration, writing a new java path for my SDK, checking my permissions and clearing my mobile's cache.
To be honest, I am not really good at understanding the logcat when it comes to files in the background that I have not seen before. Apparently, the app does not find my Fileprovider class. I defined the Fileprovider in my manifest file and wrote a corresponding file_path.xml file. I could not find the need of a specific Java provider.class nor any gradle dependencies to make a fileprovider work.
I am excited what you say to my problem and to my logcat. I appreciate every useful information!
Thank you for reading.
My Logcat:
java.lang.RuntimeException: Unable to instantiate application com.example.loginandregister.MainActivity: java.lang.ClassCastException: com.example.loginandregister.MainActivity cannot be cast to android.app.Application
at android.app.LoadedApk.makeApplication(LoadedApk.java:979)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6030)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.ClassCastException: com.example.loginandregister.MainActivity cannot be cast to android.app.Application
at android.app.Instrumentation.newApplication(Instrumentation.java:1108)
at android.app.Instrumentation.newApplication(Instrumentation.java:1093)
at android.app.LoadedApk.makeApplication(LoadedApk.java:973)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6030)
at android.app.ActivityThread.-wrap1(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1764)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
My Manifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.retrofit_uploadmediafiles">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ImageActivity"/>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.example.retrofit_uploadmediafiles.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/provider_paths"/>
</provider>
</application>
My Gradle file (I included many dependencies out of desperation ...):
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.retrofit_uploadmediafiles"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.test:runner:1.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.afollestad.material-dialogs:core:0.9.4.5'
implementation 'com.github.bumptech.glide:glide:4.11.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
implementation "androidx.multidex:multidex:2.0.1"
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
}
My Main Activity:
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
private Button image, video, pdf;
#Override
protected void onCreate(Bundle savedInstanceState) {
MultiDex.install(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image = findViewById(R.id.image);
video = findViewById(R.id.video);
pdf = findViewById(R.id.Pdf);
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
image.setEnabled(false);
video.setEnabled(false);
pdf.setEnabled(false);
ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
} else {
image.setEnabled(true);
video.setEnabled(true);
pdf.setEnabled(true);
}
image.setOnClickListener(this);
video.setOnClickListener(this);
pdf.setOnClickListener(this);
}
#Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if(requestCode == 0 ) {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
image.setEnabled(true);
video.setEnabled(true);
pdf.setEnabled(true);
}
}
}
#Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.image:
Intent intent = new Intent(this, ImageActivity.class);
startActivity(intent);
break;
case R.id.video:
//Intent intent2 = new Intent(this, VideoActivity.class);
//startActivity(intent2); I am trying to make the image upload work for now
break;
case R.id.Pdf:
//Intent intent3 = new Intent(this, PdfActivity.class);
//startActivity(intent3);
break;
}
}
}
I am a little bit overwhelmed by all these different software versions on my phone:
Android version: 8.0.0
Samsung Experience version: 9.0
Knox version:3.0, API level 24
Let me know if you need more information
I have solved this problem. I set androidx.core:core:1.8.0 in build.gradle inside defaultConfig.
configurations.all {
resolutionStrategy {
force 'androidx.core:core:1.8.0'
}
}
Then change compileSdkVersion to 32.
Clean project and rebuild project, finally everything be ok.
The AppCompat dependency compiles the Fileprovider which is within the androidx.core:core package as its dependency. Therefore remove this line implementation 'androidx.core:core:1.3.0' from your gradle file to see if it works. Because appcompat lib has version 1.1.0 while u still compiled 1.3.0 in your project.
I made a simple app with a webview and published it to the playstore - everything worked fine. Recently i updated the ip of the webview, changed the version code, generated a signed apk and re-uploaded to playstore. However, when i downloaded it to test, it crashes.
08-21 03:48:34.916 926-4059/? I/ActivityManager: START u0
{act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER]
flg=0x10000000 pkg=com.rayzor536.appointments
cmp=com.rayzor536.appointments/.MainActivity} from uid 10039
08-21 03:48:34.995 926-4061/? I/ActivityManager: Start proc 703
4:com.rayzor536.appointments/u0a137 for activity
com.rayzor536.appointments/.MainActivity
08-21 03:48:35.149 7034-7034/? I/zygote: Rejecting re-init on previously-failed class java.lang.Class<com.rayzor536.appointments.MainActivity>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
08-21 03:48:35.149 7034-7034/? I/zygote: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/lib/arm, /system/lib, /system/vendor/lib]]
08-21 03:48:35.152 7034-7034/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rayzor536.appointments, PID: 7034
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.rayzor536.appointments/com.rayzor536.appointments.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.rayzor536.appointments.MainActivity" on path: DexPathList[[zip file "/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/lib/arm, /system/lib, /system/vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2680)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6499)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.rayzor536.appointments.MainActivity" on path: DexPathList[[zip file "/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2670)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2857)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1590)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6499)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Suppressed: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v7/app/AppCompatActivity;
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
... 12 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.app.AppCompatActivity" on path: DexPathList[[zip file "/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rayzor536.appointments-ijS7lUJ8dmD9B9er-lMpYw==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 15 more
08-21 03:48:35.157 926-5481/? W/ActivityManager: Force finishing activity com.rayzor536.appointments/.MainActivity
08-21 03:48:35.173 926-1066/? I/ActivityManager: Showing crash dialog for package com.rayzor536.appointments u0
08-21 03:48:35.662 926-1065/? W/ActivityManager: Activity pause timeout for ActivityRecord{6e9e3f1 u0 com.rayzor536.appointments/.MainActivity t1469 f}
08-21 03:48:35.895 926-1416/? I/WindowManager: Failed to capture screenshot of Token{26fabd6 ActivityRecord{6e9e3f1 u0 com.rayzor536.appointments/.MainActivity t1469 f}} appWin=Window{313f14f u0 Splash Screen com.rayzor536.appointments EXITING} drawState=4
08-21 03:48:42.402 926-5481/? W/ActivityManager: Force finishing activity com.rayzor536.appointments/.MainActivity
08-21 03:48:42.404 926-5481/? I/ActivityManager: Killing 7034:com.rayzor536.appointments/u0a137 (adj 900): crash
my gradle file is below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.rayzor536.appointments"
minSdkVersion 23
targetSdkVersion 27
versionCode 3
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFile 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.android.support:multidex:1.0.3'
}
Here is my app manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.rayzor536.appointments">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
<activity android:name="com.rayzor536.appointments.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
the error line
Didn't find class "com.rayzor536.appointments.MainActivity"
says that somewhere you have been messed up with the android manifest.xml file
once check if the manifest file is good after changing your version code.
im trying to use android directory picker in an application that i am building. this is net.bgreco.DirectoryPicker. my application is called WebDownloader. it seems to run fine. and i am able to launch the directory picker application on its own but when i try to launch it as an activity from my main activity i error mentioned in the title of post.
07-15 21:36:58.740
31945-31945/com.example.zacharymcdaniel.webdownloader
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.zacharymcdaniel.webdownloader, PID: 31945
java.lang.NoClassDefFoundError: Failed resolution of:
Lnet/bgreco/R$layout;
at net.bgreco.DirectoryPicker.onCreate(DirectoryPicker.java:70)
at android.app.Activity.performCreate(Activity.java:6980)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"net.bgreco.R$layout" on path: DexPathList[[zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/base.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_dependencies_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_0_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_1_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_2_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_3_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_4_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_5_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_6_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_7_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_8_apk.apk",
zip file
"/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.zacharymcdaniel.webdownloader-y2pFpZ6io92LNAzJNpMhyw==/lib/x86,
/system/lib, /system/vendor/lib]]
at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at net.bgreco.DirectoryPicker.onCreate(DirectoryPicker.java:70)
at android.app.Activity.performCreate(Activity.java:6980)
at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6540)
at java.lang.reflect.Method.invoke(Native Method)
at
com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
WebDownloader and DirectoryPicker are both the top level folders in my android project structure. here is my app gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.zacharymcdaniel.webdownloader"
minSdkVersion 19
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile 'io.reactivex:rxjava:1.1.6'
compile 'io.reactivex:rxandroid:1.2.1'
compile files('libs/directorypicker.jar')
}
and my manifest:
`<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.zacharymcdaniel.webdownloader">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="net.bgreco.DirectoryPicker"/>
</application>
</manifest>`
and my manifest for DirectoryPicker:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.bgreco"
android:versionCode="2"
android:versionName="1.0.1">
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".DirectoryPicker"
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>
i am trying to make it so that i can launch the directory picker with an Intent and startActivityForResult. please help me find out what is wrong.
I want to read SMS using a content resolver. I've added permissions in the manifest file like this:
<uses-permission android:name="android.permission.READ_SMS"/>
Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Uri uriSMSURI = Uri.parse("content://sms/inbox");
Cursor cur = getContentResolver().query(uriSMSURI, null, null, null, null); //line that gives exception
cur.close();}
But it's giving an error:
02-22 02:55:36.429 18963-18963/inc.osi.imossis E/AndroidRuntime: FATAL EXCEPTION: main
Process: inc.osi.imossis, PID: 18963
java.lang.RuntimeException: Unable to start activity ComponentInfo{inc.osi.imossis/inc.osi.imossis.MainActivity}: java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms/inbox from pid=18963, uid=10059 requires android.permission.READ_SMS, or grantUriPermission()
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider uri content://sms/inbox from pid=18963, uid=10059 requires android.permission.READ_SMS, or grantUriPermission()
at android.os.Parcel.readException(Parcel.java:1599)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:421)
at android.content.ContentResolver.query(ContentResolver.java:491)
at android.content.ContentResolver.query(ContentResolver.java:434)
at inc.osi.imossis.MainActivity.onCreate(MainActivity.java:30)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
The complete manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="inc.osi.imossis">
<uses-permission android:name="android.permission.READ_SMS"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
How do I solve it?
Have you tried cleaning and re-building the project?
edit: Can you try checking and requesting the permission at run-time?
final private int REQUEST_READ_SMS_ID = 1; // A constant needed for callback
int hasReadSMSPermission = checkSelfPermission(Manifest.permission.READ_SMS);
if (hasReadSMSPermission != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[] {Manifest.permission.hasReadSMSPermission }, REQUEST_CODE_ASK_PERMISSIONS);
return;
}`
Uninstall the app and install again and try.
As manifest changes does not reflect on re-installations sometimes.
If I am not wrong, may be you have modifies the manifest file after installation.
Just try your luck, it may work.
So I found the problem after 2 days of Headbanging search for solution there is a bug in Emulator of API 23 if Any one Else faces this problem just run it on a different device or on emulator of api level 18 or 19 it'll work. Thanks