我正在努力用MobileVLCKit和cocoapods构建我的项目.在不添加任何VLCKit代码的情况下,我在模拟器或设备上构建应用程序时会出错.
Pod文件:
platform :ios, '8.0'
target 'VLCKitTest' do
pod 'MobileVLCKit'
end
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误
Undefined symbols for architecture arm64:
"std::runtime_error::runtime_error(std::string const&)", referenced from:
libebml::CRTError::CRTError(std::string const&, int) in MobileVLCKit(StdIOCallback.o)
"std::ostream& std::ostream::_M_insert<void const*>(void const*)", referenced from:
libebml::IOCallback::writeFully(void const*, unsigned long) in MobileVLCKit(IOCallback.o)
libebml::IOCallback::readFully(void*, unsigned long) in MobileVLCKit(IOCallback.o)
[...]
Run Code Online (Sandbox Code Playgroud)
我的部署目标是8.0.我在Debug中将"Build Active Architecture Only"设置为YES.
非常感谢你的帮助!
我正在尝试将文件上传到 Google 云端硬盘,并让用户选择用于上传的 Google 帐户。
我正在遵循本指南: https ://developers.google.com/drive/api/guides/manage-uploads
如前所述,它需要一些 OAuth 凭据才能连接到 Drive API:
Run Code Online (Sandbox Code Playgroud)// Load pre-authorized user credentials from the environment. // TODO(developer) - See https://developers.google.com/identity for // guides on implementing OAuth2 for your application.
我已设法从 One Tap 客户端获取一个SignInCredential对象,但现在我尝试将其转换为GoogleCredentialsGoogle Drive API 的对象。
使用指南中的代码
GoogleCredentials.getApplicationDefault()
.createScoped(Arrays.asList(DriveScopes.DRIVE_FILE))
Run Code Online (Sandbox Code Playgroud)
...最终导致崩溃:
应用程序默认凭据不可用。
如果我尝试自己创建凭据
val accessToken = AccessToken(token, Date(0L))
val credentials: GoogleCredentials = GoogleCredentials.create(accessToken)
Run Code Online (Sandbox Code Playgroud)
我也最终陷入崩溃:
java.lang.IllegalStateException:OAuth2Credentials实例不支持刷新访问令牌。应使用具有新访问令牌的实例,或支持刷新的派生类型。
我们在这里应该做什么?
我有使用Moshi 1.8.0进行数据序列化/反序列化的工作代码
现在,升级到1.9.1会导致尝试序列化时崩溃:
java.lang.IllegalArgumentException:无法序列化Kotlin类型com.xxx.Spot。不使用kotlin-reflect的Kotlin类的反射序列化具有未定义和意外的行为。请使用moshi-kotlin构件中的KotlinJsonAdapter或使用moshi-kotlin-codegen构件中的代码gen。
这是序列化器代码:
val moshi = Moshi.Builder().build()
val dataListType = newParameterizedType(List::class.java, T::class.java)
val adapter: JsonAdapter<List<T>> = moshi.adapter(dataListType)
val json = adapter.toJson(dataList)
Run Code Online (Sandbox Code Playgroud)
相应的T类是
@IgnoreExtraProperties
data class Spot(
var id: String = "",
var localizedName: String? = null,
var type: String = "",
var location: Location? = null
)
Run Code Online (Sandbox Code Playgroud)
我完全不知道在这里做什么。
谢谢您的帮助!
在我的代码中的某个地方,我有一个非常标准的列表,其中包含以下部分:
var body: some View {
List {
ForEach(userData.groupedBookings) { group in
Section(header: Text(group.key)) {
ForEach(group.items) { booking in
LessonRow(booking: booking)
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
不知何故,使用这段代码,这些部分是可扩展/可折叠的,这让我很高兴,但我不知道为什么。我特别沮丧,因为我想用类似的代码在其他地方重现这种行为,但没有展开/折叠。
自动获取这个的要求是什么?
如果我定义一个枚举类,让我们说:
enum class MyEnum { }
Run Code Online (Sandbox Code Playgroud)
我可以执行以下操作,因为枚举类都有一个values方法:
val values = MyEnum.values()
Run Code Online (Sandbox Code Playgroud)
现在我希望我的枚举实现一个接口并可以访问 values() 方法:
enum class MyEnum : EnumInterface { }
interface EnumInterface {
fun values() : Array<T>
fun doStuff() {
this.values()
}
}
Run Code Online (Sandbox Code Playgroud)
这不会编译,我确定如何键入 values 方法。是否可以定义这样的接口?谢谢!
我正在尝试在我的活动和片段之间共享一个 ViewModel。我的 ViewModel 包含一个report,这是一个我无法序列化的复杂对象。
protected val viewModel: ReportViewModel by lazy {
val report = ...
ViewModelProviders.of(this, ReportViewModelFactory(report)).get(ReportViewModel::class.java)
}
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试访问片段中的视图模型,但我不想再次传递所有工厂参数。
如ViewModelProvider.get文档所述:
返回一个现有的 ViewModel 或在范围内创建一个新的
我想访问活动中定义的 ViewModel 实例,因此我尝试了以下操作,但它在逻辑上崩溃了,因为模型没有空的构造函数:
protected val viewModel: ReportViewModel by lazy {
ViewModelProviders.of(requireActivity()).get(ReportViewModel::class.java)
}
Run Code Online (Sandbox Code Playgroud)
应该如何在片段中访问其“工厂化”的 ViewModel?我们应该将工厂传递给片段吗?
谢谢!
到目前为止,我已经考虑了将日期导出到以后可以导入的文件的稳定代码.我发现了一个我在这里硬编码的奇怪案例:
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MM/dd/yy HH:mm:ss"];
NSString *sd = @"03/26/17 02:30:35";
NSString *ed = @"03/26/17 05:10:17";
NSLog(@"sd = %@", [df dateFromString:sd]);
NSLog(@"ed = %@", [df dateFromString:ed]);
Run Code Online (Sandbox Code Playgroud)
这使:
sd = (null)
ed = Sun Mar 26 05:10:17 2017
Run Code Online (Sandbox Code Playgroud)
有人有提示吗?
非常感谢!
我刚刚发现使用 API 24 的 Pixel 模拟器出现永久性崩溃。我的真实设备和其他一些模拟器没有此错误。
我正在做的事情如下:在一个片段中,我尝试使用以下代码添加另一个片段:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val fragmentTransaction = requireFragmentManager().beginTransaction()
val fragment = ComposableTableReportFragment.newInstance(null)
fragmentTransaction.add(R.id.tableContainer, fragment)
fragmentTransaction.commit()
Run Code Online (Sandbox Code Playgroud)
这会导致我的应用程序启动时发生以下崩溃。
E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.pokeranalytics.android, PID: 20332
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:2080)
at androidx.fragment.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:2106)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:683)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:637)
at net.pokeranalytics.android.ui.fragment.StatisticsFragment.initUI(StatisticsFragment.kt:71)
at net.pokeranalytics.android.ui.fragment.StatisticsFragment.onViewCreated(StatisticsFragment.kt:62)
Run Code Online (Sandbox Code Playgroud)
我已经尝试过各种方法,因为崩溃非常频繁,但似乎每个案例都是独特的,并且没有找到适合我的解决方案。谢谢你的帮助!
android ×4
kotlin ×4
class ×1
enums ×1
expandable ×1
fragment ×1
google-oauth ×1
interface ×1
ios ×1
ios8 ×1
moshi ×1
objective-c ×1
swift ×1
swiftui ×1
swiftui-list ×1
viewmodel ×1
vlc ×1