2013-08-22 28 views
0

正如標題所述,即使我很確信自己已獲得Android Manifest中的正確代碼,我仍然遇到了該特定錯誤。我已經檢查了常見的錯誤,如偶然輸入「用戶」而不是「用」,並確保我使用單數「許可」。儘管我盡了最大的努力,但我仍然遇到這個錯誤。我希望你們其中一位能指出我失蹤的事情。錯誤:「您必須擁有INTERNET和ACCESS_NETWORK_STATE權限」與AdMob

下面是Android清單

<activity android:name="com.google.ads.AdActivity" 
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" > 
</activity> 
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 

相關部分及這裏的數字應顯示測試廣告我佈局的整體。相關視圖位於最底部附近。

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:paddingLeft="@dimen/activity_horizontal_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
android:paddingBottom="@dimen/activity_vertical_margin" 
tools:context=".HomeActivity" > 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:paddingLeft="0dp" 
    android:paddingRight="0dp" 
    android:paddingTop="0dp" 
    android:paddingBottom="0dp" 
    android:layout_weight=".5" 
    tools:context=".HomeActivity"> 

    <!-- Space reserved for buttons at top of screen --> 

</LinearLayout> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:paddingLeft="0dp" 
    android:paddingRight="0dp" 
    android:paddingTop="0dp" 
    android:paddingBottom="0dp" 
    android:layout_weight="1" 
    tools:context=".HomeActivity"> 

    <Button 
     android:id="@+id/btnAddRevenue" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:layout_alignParentLeft="true" 
     android:text="@string/btnAddRevenue_Text" /> 

    <Button 
     android:id="@+id/btnAddExpense" 
     android:layout_width="0dp" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:layout_alignParentRight="true" 
     android:text="@string/btnAddExpense_Text" /> 

</LinearLayout> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:paddingLeft="0dp" 
    android:paddingRight="0dp" 
    android:paddingTop="0dp" 
    android:paddingBottom="0dp" 
    android:layout_weight="5" 
    tools:context=".HomeActivity"> 

    <ListView 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" /> 

    <!-- <TextView 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:text="@string/fillerText" /> --> 
</LinearLayout> 

<LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:paddingLeft="0dp" 
     android:paddingRight="0dp" 
     android:paddingTop="0dp" 
     android:paddingBottom="0dp" 
     android:layout_weight=".5" 
     tools:context=".HomeActivity"> 

    <!-- Space reserved for ads --> 
    <com.google.ads.AdView 
     android:id="@+id/adHome_bottomBanner" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     ads:adUnitId="@string/adId_bottomBanner" 
     ads:adSize="BANNER" 
     ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" 
     ads:loadAdOnCreate="true" /> 

</LinearLayout> 

+0

你在哪裏添加admob id? – Shrikant

回答

1

我想這是因爲你裏面加<application>權限。你應該在<manifest>標籤內寫下它。

這裏是示例代碼。

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.stackdemo" 
    android:versionCode="1" 
    android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="16" /> 

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

<application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name="com.example.stackdemo.MainActivity" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

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

</manifest> 
+0

請讓我知道它是否適合你。 –

+0

我*認爲*已經奏效,但我只想讓廣告展示給您帶來挫敗感。通過實施您的修復程序,該信息確實消失了,但廣告也一樣!現在我什麼都得不到。在Logcat中,我收到一條錯誤消息,指出廣告需要更多空間。說它想要<480, 75>那就是有<432, 46>。這是完整的BS,因爲我一直給它提供越來越多的空間,改變重量值並刪除其他視圖,而那些「有」的值完全沒有改變。移動開發很酷,但這非常令人沮喪。 – Megacannon

+0

好的。我終於得到了廣告的工作。事實上,你的解決方案是解決我最初遇到的問題。十分感謝。 – Megacannon

0

試試這個::

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

我有同樣的問題。但我已經在清單中寫過這樣的文字,並且爲我工作。我認爲某種錯誤。

希望它有助於!

相關問題