導入 com.google.android.vending 無法在導入的 android 項目中解析 (The import com.google.android.vending cannot be resolved in an imported android project)


問題描述

導入 com.google.android.vending 無法在導入的 android 項目中解析 (The import com.google.android.vending cannot be resolved in an imported android project)

I have just imported an android project and when I am trying to run it it is giving me error on the following imports

import com.google.android.vending.licensing.AESObfuscator;
import com.google.android.vending.licensing.LicenseChecker;
import com.google.android.vending.licensing.LicenseCheckerCallback;
import com.google.android.vending.licensing.ServerManagedPolicy;

Any help resolving this would be greatly appreciated.


參考解法

方法 1:

You’re getting those errors because you didn’t import the licensing library. 

Go into the folder where u downloaded the android‑sdks stuff.

So there are 2 things: I) a Licensing Library and II) the Sample Licensing App

I) The licensing library is located in:

UserName/android‑sdks/extras/google/play_licensing/library

II) The Sample Licensing App is located in:

UserName/android‑sdks/extras/google/play_licensing/sample

OR

In Eclipse, File‑> New ‑> Other… ‑> Android Sample Project ‑> (Choose a Target and hit next) ‑> Google Play Licensing Library

Step 1: 

In Eclipse, Go to File‑> New ‑> Other… ‑> Android Project from Existing Code ‑> (Locate the library, ie= UserName/android‑sdks/extras/google/play_licensing/library)

Step 2:

Once you have the library imported to Eclipse, right click on the package and go to Properties ‑> Android. Make sure the “Is Library” option is checked. 

Step 3:

In Eclipse, File‑> New ‑> Other… ‑> Android Sample Project ‑> (Choose a Target and hit next) ‑> Google Play Licensing Library. My package was named “play_licensing_sample” by default. 

Step 4:

Right click on “play_licensing_sample” and go to Properties‑> Android ‑> Add… ‑> (Choose the Licensing Library u made in Step 2)‑> Apply

You’re done!

方法 2:

I ran into this issue when trying to set up my Android project for an APK expansion file.

The following steps resolved it for me:

  • Add downloader_library to eclipse as a "project from existing source" (it has errors)
  • Add licensing library to eclipse as a "project from existing source"
  • Add licensing library to downloader_library project

方法 3:

In android studio 2.2.3 I was able to fix the "package com.google.android.vending.licensing does not exist" error by:

  • Right click the downloader_library module from your project view
  • Select "Open Module Settings"
  • Select "Dependencies" Tab
  • Press plus sign + then select "3 Module Dependency"
  • Select "market_licensing" and press OK.

Original writeup of fix at https://kitefaster.com/2017/02/15/expansion‑apk‑files‑android‑studio/

方法 4:

It took me 2 days to resolve this in my project 1)I discovered the folder here

2)created a folder here

3)copied the files (less the UTIL folder) here

enter image description here

方法 5:

In Android studio you need to add a folder same level as java(folder) called aidl. Take a look at the image for more specific.

You can get those file here ‑ https://android.googlesource.com/platform/development.git/+/b8168f27f6f5b6b0ced5ef3210c0e89e8d3a5ae2/samples/MarketLicensing/src/com/android/vending/licensing

(by LondonUKGeneMattwarooKenneth WrightA J)

參考文件

  1. The import com.google.android.vending cannot be resolved in an imported android project (CC BY‑SA 3.0/4.0)

#android-lvl #Android






相關問題

這種 Google LVL 政策實施是否合理安全? (Would this Google LVL policy implementation be reasonably secure?)

在 SDK 管理器中找不到 Google 市場許可包 (Cant find Google Market Licensing package in SDK Manager)

在 Google Play 上查詢應用程序當前版本的更快方法? (Faster Way to Query Application's Current Version on Google Play?)

Android 應用許可檢查 (Android app licensing check)

Ứng dụng Giấy phép Android hiển thị Không được cấp phép? (Android License App showing Not-licensed?)

導入 com.google.android.vending 無法在導入的 android 項目中解析 (The import com.google.android.vending cannot be resolved in an imported android project)

Android“Not_Market_Managed”錯誤 (Android “Not_Market_Managed” error)

是否可以向服務添加許可證檢查(使用許可證驗證庫)? (Is it possible to add a license check (using License Verification Library) to a Service?)

應用程序許可和 android 唯一 ID (Application Licensing and android unique id)

Android 許可 - 每個 Android 開發者帳戶只有一個公鑰? (Android Licensing - Only one public key per Android Developer account?)

測試 Android LVL,許可證檢查總是失敗,沒有網絡 (Testing Android LVL, license check always fails with no network)

什麼時候從服務器返回 LICENSED_OLD_KEY? (When is LICENSED_OLD_KEY returned from server?)







留言討論