admob 違規: Valuable inventory: Scraped content, Valuable Inventory: No content

 今早又收到兩個admob違規, 而且還是複合式違規: Valuable inventory: Scraped content, Valuable Inventory: No content

讓我們來看看:

嚇傻app開發者違規警告!


全英文~~~ 要看完可累了.

還是一樣老樣子,admob不告訴你app何處違規,只叫你檢查app所有地方.

幾年了還是一樣不改作風.這可是會把新手開發者嚇傻了,

還好我經歷過很多次,習慣了.....不怕不怕...


因為我這app是用youtube api 做的tv app.

其實也就是拿別人的內容,的確是不合規矩.

只好把app內所有admob都移除了.再更新app,重新上架.過了幾天後...申訴...

但是...問題來了...ads都移除了...但admob還是給我判違規.

Valuable inventory: Scraped content:

As stated in our Program policies, we may not show Google ads on pages or apps with little or no value and/or excessive advertising to the user. This includes pages or apps that are scraping or rewriting of content from other sources without adding value. Please see Google's Webmaster quality guidelines for thin content with little or no added value for more information. 

這個就...讓我狐疑了很久...


哈哈哈,真是admob有夠爛~~~

我都因為不知那裡有問題,所以把廣告欄位全都移除了.都決定以後不加廣告了!!!

他們到底是怎麼樣阿???

現在完全不知道怎麼辦????!!



-----

更新TV app紀實:

沒辦法,要增加功能阿! 不然admob審核不會過的.



 至於要增加甚麼功能呢? 我也在努力想....(其實目前功能是夠了,但Admob找麻煩,一定要增加功能與更新app我才能再送審核..)

所以目前就想要增加:

1.Music 

2.Login + save 我的最愛吧.

為了想這個新增功能,又花了我七八天在思考...

-----

遇到youtube api issue:


 模擬器因為沒有裝youtube app所以不能進去app.

(我這app其實就是利用youtube api,所以需要相關app偕同工作)

當然很多人就會寫信給我問我,這樣不就是用youtube app就好了啊?為啥要用你的app.

首先. 身為一個程式設計師,就要學習用youtube api, 將來設計app時,比如說設計學習英文的app,或是其他需要播放影片的需求,

都有可能會用到.

但我設計這app目的除了練習用youtube api外,也希望做出不同於youtube app的體驗.

一切都是嘗試.也許那一天我設計的app會比youtube app還更好,這也是google 開放 youtube api的目的.

尤其,youtube app功能太複雜了.

我設計的這個app精簡多了,讓大家用 手機看電視可以簡單幾個步驟就能看電視,看新聞.

--------

api level 30後 , 遇到了 YouTubeInitializationResult.SERVICE_MISSING error:

The value YouTubeInitializationResult errorReason in the callback onInitializationFailure is SERVICE_MISSING.


step1: 寫了一個function去偵測youtube app是否存在!

issue: Your device/emulator is probably missing the YouTube application or, if installed, it is too old .


public static boolean isAppAvailable(final Activity act, final String package_name)
{

if( act == null || package_name == null || package_name.trim().isEmpty() )
{
return false;
}

PackageManager pm = act.getPackageManager();
boolean installed;
try
{
pm.getPackageInfo(package_name, PackageManager.GET_ACTIVITIES);
installed = true;
}
catch(PackageManager.NameNotFoundException e)
{
installed = false;
e.printStackTrace();
}
return installed;
}

上面的code在android 11後會失效,永遠failed.

so....

step2: android 11 後需要增加一些code:

因為要去偵測youtube app是否有安裝,別的app要檢查這,就要用偵測package name的方式:

但現在有了限制:

The issue with Android 11 is the os is restricting access to other apps.

https://developer.android.com/training/basics/intents/package-visibility 

Add the following to manifest tag in AndroidManifest to fix YouTube issue:

<queries>
   <intent>
     <action android:name="com.google.android.youtube.api.service.START" />
   </intent>
</queries>
 

 
然後第一個問題就解了: 偵測youtube app存在的bug.

....

然後,到目前為止,還是不能送審admob,因為根本還沒增加到新功能....

苦!!!



-----

問題3: ListView setOnItemClickListener not working

上面的listview 發現會點了之後沒作用... 

<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Cornsilk"
android:minHeight="120dp" /> 

因為我是用customview...

一行包含三個元素:

縮圖,標題,最愛.這三個.

所以又要在加一行修正: Also you have to add 

android:descendantFocusability="blocksDescendants"

to main(first level) layout

(There is even more elegant solution. Try to add android:descendantFocusability="blocksDescendants" in root layout of list element. That will make clicks onListItem possible and separately u can handle Button or ImageButton clicks)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="?android:attr/activatedBackgroundIndicator"
android:descendantFocusability="blocksDescendants"
android:gravity="center"
android:minHeight="100dp"
android:orientation="horizontal">

<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/thumbnail"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_weight="1"
android:adjustViewBounds="true"
android:minWidth="10dp"
android:minHeight="10dp"
android:scaleType="centerInside"
android:src="@drawable/no_thumbnail" />

<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="3dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:maxLines="6"
android:text="-"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@android:color/black" />

<ImageButton
android:id="@+id/btn_love"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@color/transparent"
android:padding="1dp"
android:scaleType="fitCenter"
android:src="@drawable/ic_love" />
</LinearLayout>


這樣終於點了我的最愛的那個星形圖示終於有了效果.

又解了一個問題.

但別高興太早,又有新問題了.youtube api 是用 fragment. 而我這app是用Android X.

兩個完全不相容.且youtube api 是用 jar形式存在,你不能更動.

---------

所以就是說有用到youtube api的 fragment/activity , 不能跟android X 的fragment並存.

這問題可嚴重, google 的 youtube api 已經好幾年沒更新了.

還在用舊版的android fragment. 而我們新的開發者已經全都改用androidx fragment.

造成不相容的情況,我們也沒法要求google 更新....

現在就卡在這裡.

AndroidRuntime: FATAL EXCEPTION: main
    java.lang.ClassCastException: VideoListDemoFragment_MyFavority cannot be cast to androidx.fragment.app.Fragment


在google 更新youtube api library前,必不能混用.

所以就不能顯示影片,只能單純用listview.

改成當user點擊後再跳到另一個activity, 而這個activity 是用傳統activity ,不是用android X的activity.

----

新問題 : 儲存 my favorite 的選擇.


當user要儲存我的最愛, 離開app後還要能回覆列表.

儲存方式有很多: gson or SharedPreferences .

但在這我不想用gson是因為又要匯入一大包library.

我想節省使用的library. 於是就發現了: 把arraylist轉成set

After API 11 the SharedPreferences Editor accepts Sets. You could convert your List into a HashSet or something similar and store it like that. When you read it back, convert it into an ArrayList, sort it if needed and you're good to go.

但後來發現太複雜...故還是用gson....幾行就搞定.


public static synchronized boolean save_my_favority(Activity act, List<?> list)
{

if( act == null )
{
return false;
}

try
{

SharedPreferences sharedPreferences = act.getSharedPreferences(STORE_FILE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();

Gson gson = new Gson();
String json = gson.toJson(list);

editor.putString(My_favitor_key, json);
editor.commit();

return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

public static synchronized ArrayList<VideoEntry> get_my_favority(final Activity act)
{

if( act == null )
{
return null;
}

SharedPreferences sharedPreferences = act.getSharedPreferences(STORE_FILE_NAME, Context.MODE_PRIVATE);

ArrayList<VideoEntry> arrayItems = null;
String serializedObject = sharedPreferences.getString(My_favitor_key, null);
if( serializedObject != null )
{
Gson gson = new Gson();
Type type = new TypeToken<List<VideoEntry>>(){}.getType();
arrayItems = gson.fromJson(serializedObject, type);
}

return arrayItems;
}

上面的code會在app 結束時,自動儲存my favorite.

回到app後會再取得上次的列表.

注意的是不要太頻繁去儲存.只在結束app時儲存一次.

 

突然的發現: android studio新增了新功能: Layout inspector:

可以立刻顯示目前手機上app顯示的layout畫面: 很方便,連邊界都有顯示出來.


 還沒完....目前還是不能admob送審...因為還沒加到新功能....跟完整測試. 

改這些....這樣做已經花了超過一週了...

做到這裡,如果是在公司裡面的話,

一定會有很多人,老闆主管惡同事們一定會找機會來罵我說在偷懶,沒進度...打混

他們都不知道我歷經了什麼....!!!@@

-------

目前大概改版完成,就是新增了我的最愛.

如何安裝 Android App Bundle (aab) issue????

遇到一個新問題:app-release.aab 怎麼安裝阿?

這不像之前apk可以用adb install....

這樣對測試來說非常困難....

因為這牽扯到Key signing, 混淆...等等問題...

Step 1: Download bundletool command-line tool

https://github.com/google/bundletool/releases 

 google 說明:

https://developer.android.com/studio/command-line/bundletool

Step 2: Generate APK Set Archive (.apks) file from .aab

Generating a Universal APK from Android App Bundle

example:
 C:\release>java -jar ../bundletool.jar build-apks --bundle=app-release.aab --output=ok.apks --mode=universal

 
INFO: The APKs will be signed with the debug keystore found at 'C:\Users\mark\.android\debug.keystore'

(Now open the Command Prompt (Windows) or Terminal (Mac) and change the directory to your Desktop folder using the CD command. To generate an APK set archive (.apks) file containing different APK files of all devices configurations your app supports, run the build-apks command as shown below.

java -jar bundletool.jar build-apks --bundle=xxx.aab --output=xxx.apks

 )

 

Step 3: Extract APK Files

rename the 「xxx.apks」 file to 「xxx.zip」  

open the xxx.zip..

你會看到一個 universal.apk....就是這個了...之後按照老方法安裝

 

 最後.來看一下成品... 加入我的最愛功能的手機電視app. (android.)

 


 

 

最後終於成功更新app並上架,

但....此時才發現英文拼字錯誤...My Favorite 拼錯成My Favority.

阿~~~好嚴重的錯誤,忙中出錯,此時又不能因為錯一個單字就重新上傳google play app store.

只好等下一版更新再修正了... 這一點小錯誤應該大家不會究責吧...畢竟已經做這app有十幾天了...

這是個免費app,完全服務性質的...app






留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

舊有app在Android 12 閃退問題& app Splash screens

google play 正式發布前測試報告...非常好用.

app bundle and bundletool. 關於aab安裝問題

關於google play console app應用程式簽署

Google Play badge徽章產生器