kagasu / GooglePlayStoreApi

Google Play Store API for .NET(unofficial)
MIT License
20 stars 6 forks source link

Download Apk Error #4

Closed mam4dali closed 6 years ago

mam4dali commented 6 years ago

hi, I get this error:

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object. at GooglePlayStoreApi.GooglePlayStoreClient.DownloadApk(String packageName) in GooglePlayStoreApi-master\GooglePlayStoreApi\GooglePlayStoreClient.cs:line 192 at Test.Program.DownloadApk(GooglePlayStoreClient client, String packageName) in GooglePlayStoreApi-master\Test\Program.cs:line 46 at Test.Program.Main(String[] args) in GooglePlayStoreApi-master\Test\Program.cs:line 119

With your code is tested: https://github.com/kagasu/GooglePlayStoreApi/tree/master/Test

code in line 192: var apkDownloadUrl = appDelivery.AppDeliveryData.DownloadUrl;

My code to specify the error: (in "GooglePlayStoreClient.cs") https://anotepad.com/notes/ks2b66 public byte[] DownloadApk(string packageName) { HeaderSet("X-DFE-Device-Id", AndroidId); HeaderSet("Accept-Language", Country.GetCountryCode()); HeaderSet("Authorization", $"GoogleLogin auth={Auth}"); var appDetail = AppDetail(packageName).Result; var offerType = appDetail.DocV2.Offer[0].OfferType; var versionCode = appDetail.DocV2.Details.AppDetails.VersionCode; var appDelivery = AppDelivery(packageName, offerType, versionCode).Result; Console.WriteLine("appDelivery: "+ appDelivery.ToString()); Console.WriteLine("offerType: " + offerType.ToString()); Console.WriteLine("versionCode: " + versionCode.ToString()); var apkDownloadUrl = appDelivery.AppDeliveryData.DownloadUrl; return client.GetByteArrayAsync(apkDownloadUrl).Result; }

Console output:

gmail gmail ??? gmail ?? ??? gmailgo gmail ?? ??? com.google.android.gm,Gmail appDelivery: { } offerType: 1 versionCode: 12

Maybe not the correct "appDelivery" variable output And that's why it makes a mistake

kagasu commented 6 years ago

Try 1.0.2. It supports purchase API.

https://github.com/kagasu/GooglePlayStoreApi/blob/d39ba04797a3d3bdce58316477e52ec2c539ee62/GooglePlayStoreApi/GooglePlayStoreClient.cs#L240-L255

mam4dali commented 6 years ago

Thank you so much The problem was solved