Я добавляю зависимости implementation 'com.android.support:multidex:1.0.3'
и defaultconfig multiDexEnabled = true
. В моем файле приложения для моего приложения теперь мой apk сборки успешно обработан, но при запуске приложения я получил ошибку в logcat:
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
Как мне решить мою проблему?
это файл моего приложения.
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);
}
});
}
}