使用Java库连接到Google Cloud Storage时,出现以下异常:
我们已经创建了Google Cloud Storage服务帐户Project,还下载了JSON文件。
下面是代码段:
struct Movie: Codable
{
let trackId: Int
let trackName: String
let trackGenre: String
let trackPrice: Int?
let longDescription: String
init(trackId: Int, trackName: String, trackGenre: String,
trackPrice:
Int?, /*trackImage: Thumbnail,*/ longDescription: String)
{
self.trackId = trackId
self.trackName = trackName
self.trackGenre = trackGenre
self.trackPrice = trackPrice ?? 0
self.longDescription = longDescription
//self.trackImage = trackImage //TODO: thumbnail: mapp url from json
}
private enum MovieCodingKeys: String, CodingKey
{
case trackId
case trackName
case trackGenre = "primaryGenreName"
case trackPrice
//case trackImage
case longDescription
}
init(from decoder: Decoder) throws
{
let container = try decoder.container(keyedBy: MovieCodingKeys.self)
trackId = try container.decode(Int.self, forKey: .trackId)
trackName = try container.decode(String.self, forKey: .trackName)
trackGenre = try container.decode(String.self, forKey: .trackGenre)
trackPrice = try container.decode(Int?.self, forKey: .trackPrice)
longDescription = try container.decode(String.self, forKey: .longDescription)
}
}
答案 0 :(得分:0)
这可能是互联网的要求。
尝试:Android Studio:<uses-permission android:name="android.permission.INTERNET" />
在Android清单上
Xamarin:
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
在Android清单上