我的应用程序在构建时没有任何错误,但是,当我在手机上运行它时,它停止工作;当我打开应用程序时,它停止工作,然后我决定在调试中运行它并查看错误通过logcat进入其中
我的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
我的MainActivity
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() {
}
}
答案 0 :(得分:0)
<item name="android:windowIsTranslucent">true</item>
将True设置为false