Мое приложение работает на Android 8.1 или выше, но приложение аварийно завершает работу при попытке запустить на Android 5.0, 6.0 или ниже версии 8.0. Пытался найти решение по inte rnet, но не нашел соответствующего ответа.
Иногда появляется сообщение об ошибке
Это отчет Logcat:
04-16 16:20:22.416 3033-3059/com.silverfoxsoft.concretepumpandconstructioncalculator E/FirebaseInstanceId: Google Play services missing or without correct permission.
04-16 16:20:22.760 3033-3063/com.silverfoxsoft.concretepumpandconstructioncalculator E/ActivityThread: Failed to find provider info for com.google.android.gms.chimera
04-16 16:20:22.762 3033-3063/com.silverfoxsoft.concretepumpandconstructioncalculator E/DynamiteModule: Failed to load IDynamiteLoader from GmsCore: Application package com.google.android.gms not found
04-16 16:20:22.764 3033-3065/com.silverfoxsoft.concretepumpandconstructioncalculator E/DynamiteModule: Failed to load IDynamiteLoader from GmsCore: Application package com.google.android.gms not found
04-16 16:20:23.009 3033-3059/com.silverfoxsoft.concretepumpandconstructioncalculator E/FirebaseInstanceId: Google Play services missing or without correct permission.
04-16 16:20:23.104 3033-3033/com.silverfoxsoft.concretepumpandconstructioncalculator E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.silverfoxsoft.concretepumpandconstructioncalculator, PID: 3033
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.silverfoxsoft.concretepumpandconstructioncalculator/com.silverfoxsoft.concretepumpandconstructioncalculator.MainActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class androidx.appcompat.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class androidx.appcompat.widget.Toolbar
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.silverfoxsoft.concretepumpandconstructioncalculator.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.silverfoxsoft.concretepumpandconstructioncalculator.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: android.content.res.Resources$NotFoundException: Resource "com.silverfoxsoft.concretepumpandconstructioncalculator:drawable/tape" (7f0700d4) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0700d4 a=-1 r=0x7f0700d4}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2390)
at android.content.res.Resources.loadDrawable(Resources.java:2330)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.view.View.<init>(View.java:3730)
at android.view.ViewGroup.<init>(ViewGroup.java:491)
at android.view.ViewGroup.<init>(ViewGroup.java:487)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:236)
at androidx.appcompat.widget.Toolbar.<init>(Toolbar.java:232)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:916)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:802)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.silverfoxsoft.concretepumpandconstructioncalculator.MainActivity.onCreate(MainActivity.java:41)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
04-16 16:20:23.962 3033-3059/com.silverfoxsoft.concretepumpandconstructioncalculator E/FirebaseInstanceId: Google Play services missing or without correct permission.
04-16 16:20:24.029 3033-3059/com.silverfoxsoft.concretepumpandconstructioncalculator E/FirebaseInstanceId: Google Play services missing or without correct permission.
04-16 16:20:24.033 3033-3059/com.silverfoxsoft.concretepumpandconstructioncalculator E/FirebaseInstanceId: Google Play services missing or without correct permission.
Отображение ошибки при (MainActivity. java : 41) а также. но почему?
My MainActivity. java Файл находится здесь:
package com.silverfoxsoft.concretepumpandconstructioncalculator;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.google.android.material.navigation.NavigationView;
import com.google.firebase.messaging.FirebaseMessaging;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private long backPressedTime;
private AppBarConfiguration mAppBarConfiguration;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel =
new NotificationChannel("Mynotification", "MyNotification", NotificationManager.IMPORTANCE_DEFAULT);
NotificationManager manager = getSystemService(NotificationManager.class);
assert manager != null;
manager.createNotificationChannel(channel);
}
FirebaseMessaging.getInstance().subscribeToTopic("general")
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
String msg = "Connected to Firebase!";
if (!task.isSuccessful()) {
msg = "Failed";
}
//Log.d(TAG, msg);
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
}
});
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Email your feedback or suggestion", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
Toast.makeText(MainActivity.this,
"Select Email option only!", Toast.LENGTH_LONG).show();
//Thread.sleep(2000);
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("plain/text");
String[] address = {"silverfoxsofts@gmail.com"};
email.putExtra(Intent.EXTRA_EMAIL, address);
email.putExtra(Intent.EXTRA_SUBJECT, "Feed Back/Suggestion for MIXO - Construction Manager App");
email.putExtra(Intent.EXTRA_TEXT, "\nType your feedback or suggestion here.\n\n");
startActivity(email);
}
});
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow,
R.id.nav_tools, R.id.nav_share, R.id.nav_send)
.setDrawerLayout(drawer)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onSupportNavigateUp() {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
return NavigationUI.navigateUp(navController, mAppBarConfiguration)
|| super.onSupportNavigateUp();
}
@Override
public void onBackPressed() {
if(backPressedTime + 2000 > System.currentTimeMillis()) {
super.onBackPressed();
} else {
Toast.makeText(MainActivity.this,
"Press back again to exit", Toast.LENGTH_LONG).show();
}
backPressedTime = System.currentTimeMillis();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.action_settings:
Toast.makeText(MainActivity.this,
"Privacy Policy", Toast.LENGTH_LONG).show();
Intent intent = new Intent(MainActivity.this, Privacy_Policy.class);
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
}
Файл манифестов:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.silverfoxsoft.concretepumpandconstructioncalculator">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<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=".Volume_Calculation_Cylinder"></activity>
<activity android:name=".Area_Converter" />
<activity android:name=".Area_Calculator" />
<activity android:name=".Volume_Calculator" />
<activity android:name=".Volume_Converter" />
<activity android:name=".Torque_converter" />
<activity android:name=".Length_Converter" />
<activity android:name=".Lpm_to_Gpm" />
<activity android:name=".Bar_to_PSI" />
<activity android:name=".Accumulator" />
<activity android:name=".SpareConsumption" />
<activity android:name=".Slide_Sales_Reporting" />
<activity android:name=".ServiceReport" />
<activity android:name=".Hyd_vs_Concrete_Pressure" />
<activity android:name=".Slurry_Calculation" />
<activity android:name=".Pipe_Line_Calculation" />
<activity android:name=".OnSIte_Pressure_Calculation" />
<activity android:name=".Capacity_Of_Pump" />
<activity android:name=".Friction_Factor" />
<activity android:name=".DataLogger" />
<activity android:name=".Ampacity" />
<activity android:name=".VA_to_Watts" />
<activity android:name=".MAh_to_Wh" />
<activity android:name=".Kw_to_KWh" />
<activity android:name=".KvaToWatts" />
<activity android:name=".VoltageDrop" />
<activity android:name=".WireGauge" />
<activity android:name=".PowerFactor" />
<activity android:name=".Electron_Volts" />
<activity android:name=".Energy_consumption" />
<activity android:name=".Amps_To_Voltage" />
<activity android:name=".Joule_To_Watt" />
<activity android:name=".AmpsToKVA" />
<activity android:name=".kW_to_HP" />
<activity android:name=".ampsToKW" />
<service android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<activity android:name=".Privacy_Policy" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/cap" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />
<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>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-4613380677660687~9880768728" />
</application>
</manifest>
(Build.gradle) Уровень проекта:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.google.gms:google-services:4.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
(Build.gradle) Уровень приложения
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "com.silverfoxsoft.concretepumpandconstructioncalculator"
minSdkVersion 19
targetSdkVersion 29
versionCode 3
versionName "1.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
implementation 'androidx.lifecycle:lifecycle-extensions:2.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.google.firebase:firebase-analytics:17.3.0'
implementation 'com.google.firebase:firebase-messaging:20.1.5'
implementation 'com.google.android.gms:play-services-ads:19.0.1'
implementation 'com.google.android.gms:play-services-base:17.2.1'
implementation 'com.google.android.gms:play-services-location:17.0.0'
}
Что я делать неправильно? Я уже опубликовал sh это приложение в магазине Google Play: вы можете проверить его @ https://play.google.com/store/apps/details?id=com.silverfoxsoft.concretepumpandconstructioncalculator