Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/183.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ADMOB-无法启动活动组件信息:java.lang.NullPointerException_Java_Android_Admob - Fatal编程技术网

ADMOB-无法启动活动组件信息:java.lang.NullPointerException

ADMOB-无法启动活动组件信息:java.lang.NullPointerException,java,android,admob,Java,Android,Admob,我所做的一切都像教程告诉AdMob站点的那样,用XML格式显示布局,导入Google Play服务路径,并添加教程中的代码行,我的应用程序可以编译,但不再在智能手机上打开 遵循代码 等级 package your.CalculoHE.namespace; import org.apache.cordova.DroidGap; import com.google.android.gms.ads.*; import android.os.Bundle; public class Calcu

我所做的一切都像教程告诉AdMob站点的那样,用XML格式显示布局,导入Google Play服务路径,并添加教程中的代码行,我的应用程序可以编译,但不再在智能手机上打开

遵循代码

等级

package your.CalculoHE.namespace;


import org.apache.cordova.DroidGap;
import com.google.android.gms.ads.*;


import android.os.Bundle;

public class CalculoHoraExtraActivity extends DroidGap {    

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.setContentView(R.layout.main);
        super.setIntegerProperty("splashscreen", R.drawable.sobreaviso);
        super.loadUrl("file:///android_asset/www/index.html", 3000);

        // Consultar o AdView como um recurso e carregar uma solicitação.
        AdView adView = (AdView)this.findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        adView.loadAd(adRequest);

    }    
   }   
main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:ads="http://schemas.android.com/apk/res-auto"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent">
  <com.google.android.gms.ads.AdView android:id="@+id/adView"
                         android:layout_width="wrap_content"
                         android:layout_height="wrap_content"
                         ads:adUnitId="ca-app-pub-*******"
                         ads:adSize="BANNER"/>

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Hora extras"
    />
</LinearLayout>

manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="your.CalculoHE.namespace"
    android:versionCode="4"
    android:versionName="1.2" >

    <uses-sdk android:minSdkVersion="9" />

    <supports-screens
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true"
        android:resizeable="true"
        android:anyDensity="true"
        />

    <application android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

       <meta-data android:name="com.google.android.gms.version"
               android:value="@integer/google_play_services_version"/>


        <activity android:configChanges="orientation|keyboardHidden" android:name=".CalculoHoraExtraActivity"
            android:label="@string/app_name" >

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.google.android.gms.ads.AdActivity"
             android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize"/>


    </application>
            <uses-permission android:name="android.permission.INTERNET"/>
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

</manifest>

尝试更改:

AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
致:


你到底是什么意思?应用程序正在崩溃,没有打开,或者只是没有可查看的广告?如果有任何崩溃,请发布堆栈跟踪。重要的是,发帖时千万不要显示你真正的成人id。将其删除或替换为“***”可能有人将其用于不好的目的,从而导致admob禁止您。MJ93,构造函数AdRequest()未定义,未打开!确保
导入com.google.ads.AdRequest已导入。构造器不需要任何参数。即使在导入之后,相同的消息仍然存在。如果您做得不对。不能同时使用“com.google.android.gms.ads.*”和“com.google.ads.*”。你必须坚持一个包裹。旧的admob sdk或通过google play服务的新admob@保罗,你说应用程序无法打开是什么意思。是否要共享堆栈跟踪(错误日志)?
AdView adView = (AdView)this.findViewById(R.id.adView);
adView.loadAd(new AdRequest());