我的应用程序在构建时没有任何错误,但是,当我在手机上运行它时它会停止工作,当我打开应用程序时它会停止工作,然后我决定在调试中运行它并通过logcat查看其中的错误
My build.gradle
apply plugin: 'com.android.application'
android {
configurations.all {exclude group: 'com.android.support', module: 'support-v4'}
compileSdkVersion 28
defaultConfig {
applicationId "tdl.com.dindim"
minSdkVersion 16
targetSdkVersion 28
multiDexEnabled true
versionCode 2
versionName "1.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
multiDexEnabled true
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:28.0.0'
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'
implementation 'com.adefruandta.spinningwheel:spinningwheel:0.1.0'
implementation 'com.google.firebase:firebase-core:10.0.1'
implementation 'com.google.firebase:firebase-database:10.0.1'
implementation 'org.immutables:gson:2.6.1'
implementation 'com.google.android.gms:play-services:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
implementation 'com.google.android.gms:play-services-ads:10.0.1'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'gun0912.ted:tedpermission:2.1.0'
}
apply plugin: 'com.google.gms.google-services'
Logcat 错误(我只是采用了红色的单词)
2019-07-19 03:33:43.960 7572-7572/? E/FirebaseInstanceId: binding to the service failed
at android.os.HandlerThread.run(HandlerThread.java:65)
2019-07-19 04:23:16.863 15686-15704/? E/DIAL:SsdpWriter: Error sending M-SEARCH request
java.net.SocketException: Socket is closed
at java.net.DatagramSocket.send(DatagramSocket.java:686)
at com.google.android.music.dial.SsdpWriter.sendSearch(SsdpWriter.java:67)
at com.google.android.music.dial.SsdpScanner.run(SsdpScanner.java:45)
at com.google.android.music.utils.async.TraceableRunnable.runLogged(TraceableRunnable.java:21)
at com.google.android.music.utils.async.LoggedRunnable.run(LoggedRunnable.java:30)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at com.google.android.music.utils.LoggableHandler.dispatchMessage(LoggableHandler.java:74)
at android.os.Looper.loop(Looper.java:164)
at android.os.HandlerThread.run(HandlerThread.java:65)
调试错误(我只是拿了红色的单词)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: tdl.com.dindim, PID: 11596
java.lang.RuntimeException: Unable to start activity ComponentInfo{tdl.com.dindim/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2830)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2909)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1606)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
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:769)
Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.Activity.onCreate(Activity.java:991)
at android.support.v4.app.SupportActivity.onCreate(ComponentActivity.java:75)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:335)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:85)
at com.gun0912.tedpermission.TedPermissionActivity.onCreate(TedPermissionActivity.java:69)
at android.app.Activity.performCreate(Activity.java:6984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1235)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2783)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2909)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1606)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
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:769)
E/UncaughtException: java.lang.RuntimeException: Unable to start activity ComponentInfo{tdl.com.dindim/com.gun0912.tedpermission.TedPermissionActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2830)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2909)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1606)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
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:769)
Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
at android.app.Activity.onCreate(Activity.java:991)
at android.support.v4.app.SupportActivity.onCreate(ComponentActivity.java:75)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:335)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:85)
at com.gun0912.tedpermission.TedPermissionActivity.onCreate(TedPermissionActivity.java:69)
at android.app.Activity.performCreate(Activity.java:6984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1235)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2783)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2909)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1606)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6592)
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:769)
E/FirebaseCrash: Unable to parse Json response string to get message: No value for crashes
我的主要活动
package tdl.com.dindim.activities;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import java.util.List;
import tdl.com.dindim.R;
import tdl.com.dindim.managers.SpinManager;
import tdl.com.dindim.managers.WithdrawManager;
import tdl.com.dindim.models.Score;
import tdl.com.dindim.models.Withdraw;
import tdl.com.dindim.utils.ApplicationMode;
import tdl.com.dindim.utils.ConnectionChecker;
import tdl.com.dindim.utils.SharedPreferenceValue;
public class MainActivity extends AppCompatActivity implements WithdrawManager.WithdrawFeedbackListener {
private TextView tvTotalEarn, tvLastWithdraw;
private AdView adView, adView2, adView3;
private InterstitialAd mInterstitialAd;
private WithdrawManager withdrawManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initUI();
}
private void initUI() {
tvTotalEarn = findViewById(R.id.tvTotalEarn);
tvLastWithdraw = findViewById(R.id.tvLastWithdraw);
adView = findViewById(R.id.adViewD);
adView2 = findViewById(R.id.adView2D);
adView3 = findViewById(R.id.adView3D);
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getString(R.string.dashboard_interstitial_ads));
loadAds();
showInterstitialAdds();
if (ConnectionChecker.isOnline(MainActivity.this)) {
new SpinManager(MainActivity.this, false, new SpinManager.SpinFeedbackListener() {
@Override
public void pointSaveSuccess() {
}
@Override
public void pointSaveFailed() {
}
@Override
public void noLastPointFound() {
tvTotalEarn.setText("My Total Earn Points: 0");
}
@Override
public void userLastScore(Score score) {
tvTotalEarn.setText("My Total Earn Points: " + score.getPoints());
}
@Override
public void updateScoreSuccess() {
}
@Override
public void updateScoreFailed() {
}
@Override
public void noScoreForTodayUpdateScoreOnly(Score score) {
tvTotalEarn.setText("My Total Earn Points: " + score.getPoints());
}
}).getUserLastScore(SharedPreferenceValue.getLoggedinUser(MainActivity.this));
withdrawManager = new WithdrawManager(MainActivity.this, false, this);
withdrawManager.getUserLastWithdraw(SharedPreferenceValue.getLoggedinUser(MainActivity.this));
} else {
Toast.makeText(this, "No internet . try to connect with internet", Toast.LENGTH_SHORT).show();
}
}
private void loadAds() {
// ads:adUnitId="ca-app-pub-4836336224499913/6703144349"></com.google.android.gms.ads.AdView>
//mAdViewTop.setAdUnitId("ca-app-pub-4836336224499913/6703144349");
if (ApplicationMode.devMode) {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("35E1AEC74E43C6B3529C4F77AC4CB10F")
.build();
adView.loadAd(adRequest);
} else {
AdRequest adRequest = new AdRequest.Builder()
//.addTestDevice("35E1AEC74E43C6B3529C4F77AC4CB10F")
.build();
adView.loadAd(adRequest);
}
if (ApplicationMode.devMode) {
AdRequest adRequest2 = new AdRequest.Builder()
.addTestDevice("35E1AEC74E43C6B3529C4F77AC4CB10F")
.build();
adView2.loadAd(adRequest2);
} else {
AdRequest adRequest2 = new AdRequest.Builder()
//.addTestDevice("35E1AEC74E43C6B3529C4F77AC4CB10F")
.build();
adView2.loadAd(adRequest2);
}
if (ApplicationMode.devMode) {
AdRequest adRequest3 = new AdRequest.Builder()
.addTestDevice("35E1AEC74E43C6B3529C4F77AC4CB10F")
.build();
adView3.loadAd(adRequest3);
} else {
AdRequest adRequest3 = new AdRequest.Builder()
//.addTestDevice("35E1AEC74E43C6B3529C4F77AC4CB10F")
.build();
adView3.loadAd(adRequest3);
}
}
private void showInterstitialAdds() {
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
// Load the next interstitial.
//mInterstitialAd.loadAd(new AdRequest.Builder().build());
}
});
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
showAdsFinal();
}
}, 5000);
}
void showAdsFinal() {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d("TAG", "The interstitial wasn't loaded yet.");
}
}
@Override
public void withdrawSaveSuccess() {
}
@Override
public void withdrawSaveFailed() {
}
@Override
public void noLastWithdrawFound() {
tvLastWithdraw.setText("My Last Withdraw: 0");
}
@Override
public void userLastWithdraw(Withdraw withdraw) {
tvLastWithdraw.setText("My Last Withdraw: " + withdraw.getWithdrawPoints());
}
@Override
public void withDrawRequests(List<Withdraw> withdrawList) {
}
@Override
public void noRequestsAvailable() {
}
}
当我在手机上运行我的android studio应用程序时,我遇到了一个错误。它说我的应用程序一直停止,不会加载。 多谢了。
这是我的XML代码 这是我的Java代码
我是android开发的初学者。我创建了一个活动并添加了一个按钮。然后,我添加了一个事件侦听器,在单击按钮时打开另一个活动。到目前为止,这两个班都是 和 MainActivity的布局文件如下 谁能告诉我这是怎么了?为什么应用程序一直停止?
----------在android上。应用程序。ActivityThread。android上的installProvider(ActivityThread.java:7447)。应用程序。ActivityThread。android上的installContentProviders(ActivityThread.java:6964)。应用程序。ActivityThread。android上的h
这就是它强调我的错误的地方。''etchirps.findViewById(r.id.etchirps);'''
总结问题 你好,开发人员,所以。。我想做一个弹出菜单,点击下面的图标,它就会出现在列表视图中的一个项目上。我想这样做,点击出现一个带有一些选项的弹出栏 描述一下你的尝试 我试着按照有关创建弹出式菜单的教程进行操作,但方法总是一样的,我对此没有问题。但它在Logcat上显示了这个空指针错误,我试图用初始化ImageView来修复它,但目前没有任何进展。。例如,我尝试执行“image=(Imagevi