提问人:Sarthak Pandey 提问时间:3/23/2020 最后编辑:Sarthak Pandey 更新时间:3/23/2020 访问量:7354
添加 MultiDex 后,我在 android studio 中遇到了运行时异常:“无法获取文件列表和 NullPointerException”
I got runtime exceptions in my android studio:"Fail to get file list and NullPointerException" after adding MultiDex
问:
我在我的应用程序 gradle 文件中添加了依赖项和 defaultconfig,现在我的构建 apk 已成功处理,但是当我运行应用程序时,我在 logcat 中出现错误:implementation 'com.android.support:multidex:1.0.3'
multiDexEnabled = true
2020-03-23 17:17:16.312 13609-13609/? E/example.sahayo: Unknown bits set in runtime_flags: 0x28000
2020-03-23 17:17:16.401 13609-13639/? E/Perf: Fail to get file list com.example.sahayog
2020-03-23 17:17:16.402 13609-13639/? E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2020-03-23 17:17:16.402 13609-13639/? E/Perf: Fail to get file list com.example.sahayog
2020-03-23 17:17:16.402 13609-13639/? E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2020-03-23 17:17:16.403 13609-13639/? E/Perf: Fail to get file list oat
2020-03-23 17:17:16.403 13609-13639/? E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
如何解决我的问题?
这是我的应用 gradle 文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.sahayog"
minSdkVersion 15
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.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.android.support:multidex:1.0.3'
}
这是我的 Java 文件。
package com.example.sahayog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.tasks.OnSuccessListener;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
public class Home extends AppCompatActivity {
//private FusedLocationProviderClient client;
@Override
public void onBackPressed() {
moveTaskToBack(true);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
Button PanicButton =(Button) findViewById(R.id.PanicButton);
final SharedPreferences result = getSharedPreferences("SAVEDATA", MODE_PRIVATE);
PanicButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent msgIntent = new Intent(getApplicationContext(), Home.class);
PendingIntent pi = PendingIntent.getActivity(getApplicationContext(),0,msgIntent, 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(result.getString("Mobile_no1","data not found"),null, "hello this is sarthak",pi, null);
Toast.makeText(Home.this, "Message sent successfully!", Toast.LENGTH_LONG).show();
//Intent callIntent = new Intent(Intent.ACTION_CALL);
//callIntent.setData(Uri.parse("tel:"+"108"));
//startActivity(callIntent);
}
});
}
}
答: 暂无答案
评论