每次尝试运行测试时都会出现以下错误。
\n\n \xe2\x97\x8f Test suite failed to run\n\n src/repositories/list_contacts/ListContactRepository.test.ts:4:37 - error TS2307: Cannot find module './ListContactRepository' or its corresponding type declarations.\n\n 4 import {ListContactRepository} from './ListContactRepository';\n ~~~~~~~~~~~~~~~~~~~~~~~~~\n
Run Code Online (Sandbox Code Playgroud)\n早些时候一切工作正常,但在我将 \n 重命名为之后发生了这种
情况src/repositories/quick_contacts/QuickListContactRepository.test.ts
src/repositories/list_contacts/ListContactRepository.test.ts
并运行git checkout -b list
。经过一些更改后,我在那里提交并返回到上一个分支,每当git checkout dev
我尝试运行测试时,我都会遇到此错误。
src/repositories/list_contacts/ListContactRepository.test.ts
我当前的分支上甚至不存在该文件。但开玩笑一直在抱怨。任何解决此问题的建议将不胜感激。
更新 AS 后,每次启动时模拟器都会退出。下面是我在它消失之前设法捕获的屏幕截图。
在日志中打印以下内容
14:49 模拟器:警告:检测到渲染器更改。
14:49 模拟器:C:\Users\Nux\AppData\Local\Android\Sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe:加载设备 'goldfish_pipe' 的实例 0x0 状态时出错
14:49 模拟器:deleteSnapshot:用于 default_boot
14:49 模拟器:qemu:不支持的键盘 cmd=0x84
14:49 模拟器:qemu:不支持的键盘 cmd=0x84
14:49 模拟器:进程完成,退出代码为 0
我已经尝试了以下方法:
他们都没有工作。任何帮助将不胜感激!
我有用 golang 编写的 Web 服务器,它使用 graphql 包gqlgen和gorm作为数据库。
\n由于 golang 可以在 Android 上编译和运行,所以我想创建我的应用程序的离线版本,其中 sqlite 可用于离线存储并将我的整个服务器导入为aar。
\n我已经按照此处的说明成功构建了aar并使用 gomobile 将其添加到我的 flutter 上
\n当我运行我的应用程序时,服务器在 Android 上启动,它似乎工作得很好,当http://localhost:8080/
在模拟器的 chrome 应用程序上打开时,我看到 graphql 游乐场运行没有任何问题,就像我在 Windows 中的浏览器上看到的那样。
我面临的唯一问题是,当服务器在后台运行时,flutter 应用程序只显示空白屏幕。以下是app启动时打印的日志
\nLaunching lib\\main.dart on sdk gphone64 x86 64 in debug mode...\nRunning Gradle task \'assembleDebug\'...\n\xe2\x88\x9a Built build\\app\\outputs\\flutter-apk\\app-debug.apk.\nInstalling build\\app\\outputs\\flutter-apk\\app.apk...\nDebug service listening on ws://127.0.0.1:62561/DyGpOhyuekw=/ws\nSyncing files to device sdk gphone64 x86 64...\nI/GoLog ( 6295): connect to http://localhost:8080/ for GraphQL playground\nW/ux.offline( …
Run Code Online (Sandbox Code Playgroud) 我是 Flutter 开发的新手,目前正在同时开发 4 个应用程序。所以我想通过创建plugin 或 package在这些应用程序之间共享代码。但我不明白在我的情况下在包或插件之间选择什么。
我将只在这个可共享的代码中编写 dart 代码,但我将使用来自pub.dev 的其他插件,其中包含本地代码,如 Kotlin 和 Swift 示例flutter_contacts,其中包含 java 和 swift 代码。
那么对于这种情况,我应该在插件和包之间选择什么。
TLDR
I updated some android studio components 2 days ago and everything messed up. Now I cant use android emulator since it exits immediately the moment it gets lunched.
I already tried the following:
我正在使用分页库从服务器获取数据,我想在每 10 个项目后显示广告。因此,当用户向下滚动并获取新项目并将其添加到 PagedList 时。我希望加载和添加新广告,RecyclerView
就像 Instagram 在提要中显示广告一样。因此,如果用户滚动到 200 个项目,将逐渐显示 20 个广告!!。我已经阅读了几个教程,但我还没有想出一个简单的方法来做到这一点。
这是我的适配器。
class RequestsPagedAdapter(
private val retryCallback: () -> Unit, private val from: From)
: PagedListAdapter<RequestsQuery.Request, RecyclerView.ViewHolder>(POST_COMPARATOR) {
private var networkState: NetworkState? = null
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
when (getItemViewType(position)) {
R.layout.z_request_item -> (holder as RequestViewHolder).bind(getItem(position)!!, from)
R.layout.network_state_item -> (holder as NetworkStateItemViewHolder).bindTo(networkState)
R.layout.ad_admob_banner -> (holder as AdMobViewHolder)
}
}
override fun onBindViewHolder(
holder: RecyclerView.ViewHolder,
position: Int,
payloads: MutableList<Any>) {
if (payloads.isNotEmpty()) {
val …
Run Code Online (Sandbox Code Playgroud) 在集成测试中,我使用以下代码段来创建连接
import {Connection, createConnection} from 'typeorm';
// @ts-ignore
import options from './../../../ormconfig.js';
export function connectDb() {
let con: Connection;
beforeAll(async () => {
con = await createConnection(options);
});
afterAll(async () => {
await con.close();
});
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试对一个在其方法之一中调用typeorm 存储库的类进行单元测试,并且没有调用上面的帮助函数connectDb()我得到以下错误,这当然是预期的。
ConnectionNotFoundError:未找到连接“默认”。
我的问题是如何模拟连接。我已经尝试了以下没有任何成功
import typeorm, {createConnection} from 'typeorm';
// @ts-ignore
import options from "./../../../ormconfig.js";
const mockedTypeorm = typeorm as jest.Mocked<typeof typeorm>;
jest.mock('typeorm');
beforeEach(() => {
//mockedTypeorm.createConnection.mockImplementation(() => createConnection(options)); //Failed
mockedTypeorm.createConnection = jest.fn().mockImplementation(() => typeorm.Connection);
MethodRepository.prototype.changeMethod = jest.fn().mockImplementation(() => { …
Run Code Online (Sandbox Code Playgroud) 我正在使用android studio 3.3,并且一切正常。但是今天更新到3.4之后,我得到了这些错误。似乎麻烦源自androidX依赖项。这也发生在依赖于AndroidX的两个不同项目中。
我尝试了以下方法:
1.清理并重建我的项目
2.使缓存无效并重新启动。
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.cursoradapter:cursoradapter:1.0.0.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.drawerlayout:drawerlayout:1.0.0.
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve …
Run Code Online (Sandbox Code Playgroud) 我正在构建一个应用程序,在该应用程序中,用户需要填写一些数据才能发布内容,因此一个片段由个EditText
单选按钮组成,并Spinner
与之一起RecyclerView
动态呈现多个包含TextView
和的子布局EditText
。
因此,当用户从中选择类别时Spinner
,将显示一些与该类别相关的属性,RecyclerView
用户可以选择填充其中的一些属性。
我尝试使用回调实现此功能,TextWatcher
但是我没有得到想要的值。
打回来
interface PropertiesCallback {
fun addProp(position: Int, title: String, value: String)
}
Run Code Online (Sandbox Code Playgroud)
适配器
class PropertiesAdapter(private val propertiesCallback: PropertiesCallback)
: RecyclerView.Adapter<PropertiesAdapter.ViewHolder>() {
private var list = listOf<CategoriesAndSubcategoriesQuery.Property>()
fun setData(listOfProps: List<CategoriesAndSubcategoriesQuery.Property>) {
this.list = listOfProps
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.z_property_input, parent, false)
return ViewHolder(view)
}
override fun getItemCount(): Int = list.size
override fun …
Run Code Online (Sandbox Code Playgroud) 我正在使用带有导航体系结构组件的底部导航。当用户从一项导航到另一项(通过底部导航)并再次返回时,查看模型调用存储库功能以再次获取数据。因此,如果用户来回移动10次,则相同的数据将被提取10次。如何在重新创建片段时避免重新获取数据?
分段
class HomeFragment : Fragment() {
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
private lateinit var productsViewModel: ProductsViewModel
private lateinit var productsAdapter: ProductsAdapter
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_home, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
initViewModel()
initAdapters()
initLayouts()
getData()
}
private fun initViewModel() {
(activity!!.application as App).component.inject(this)
productsViewModel = activity?.run {
ViewModelProviders.of(this, viewModelFactory).get(ProductsViewModel::class.java)
}!!
}
private fun initAdapters() {
productsAdapter = ProductsAdapter(this.context!!, …
Run Code Online (Sandbox Code Playgroud) android android-architecture-lifecycle android-architecture-components android-architecture-navigation
android ×6
flutter ×2
jestjs ×2
kotlin ×2
admob ×1
android-architecture-components ×1
android-architecture-lifecycle ×1
android-architecture-navigation ×1
go ×1
gomobile ×1
gqlgen ×1
gradle ×1
node.js ×1
typeorm ×1
typescript ×1
unit-testing ×1