我已经安装了 .NET 6(版本6.0.100-rc.1.21458.32)和 Visual Studio 2020 Preview(尽管它可能不是先决条件)。
我正在尝试调试 hello-world 应用程序,但收到有关 Java 的构建错误。
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\31.0.100-rc.1.12\targets\Microsoft.Android.Sdk.Tooling.targets(20,5): error XA0031:
Java SDK 11.0 or above is required when using .NET 6 or higher.
Run Code Online (Sandbox Code Playgroud)
我已经安装了 Java 17 设置Path,并指向 Visual Studio 设置中的 Java 开发工具包位置(工具->选项->Xamarin->Android 设置)。因为这不起作用,我已将 JDK 位置设置为 Microsoft 的 openjdk,但它仍然不起作用。
这是怎么回事?
WiFi感知和WiFi P2P技术之间的主要区别是什么?
使用 WiFi P2P,您可以在不需要公共网络的情况下在两个或多个附近设备之间建立连接。但 android 文档规范也说明
Wi-Fi 感知功能使运行 Android 8.0(API 级别 26)及更高版本的设备能够发现并直接相互连接,而无需它们之间的任何其他类型的连接。
它们之间有什么区别?
编辑:
为了在Android环境之外测试这个问题,我创建了一个Java应用程序来创建一个ExecutorService,提供AttackScript(相同类)的任务然后终止.
这按预期工作100%,线程中断并且任务停止.
您甚至不必通过它取消任务Future.cancel(true).ExecutorService.shutdownNow()做的工作.Android中有什么东西在Service某种程度上与线程池混淆了吗?
作为被截取的代码:
public static void main(String[] args) {
AttackScript script = new AttackScript("http://ninjaflex.com/");
ExecutorService executor = Executors.newFixedThreadPool(5);
executor.submit(script);
executor.submit(script);
executor.submit(script);
executor.submit(script);
sleep(1300);
// Automatically interrupts threads in the pool.
executor.shutdownNow();
}
private static void sleep(long timeMilli){
try {
Thread.sleep(timeMilli);
} catch(Exception e) {
System.out.println("Error sleep()");
}
}
Run Code Online (Sandbox Code Playgroud)
原帖:
我有一个Android Service,它包含一个ExecutorService字段,负责运行一些任务.
任务是AttackScript类的对象.我将Future引用缓存在一个Map<String,Future>名为tasks的内容中,这样我以后就可以取消它们了.
Future future = executor.submit(new AttackScript(attack.getWebsite())); …Run Code Online (Sandbox Code Playgroud) 我不明白为什么有人要使用命名的路线,Navigator.pushNamed()而不是在正常的 方式用Navigator.push()。
该教程页指出:
如果我们需要在应用程序的许多部分导航到同一个屏幕,这可能会导致代码重复。在这些情况下,定义“命名路线”并使用命名路线进行导航会很方便
使用简单路由时将如何生成重复以及如何使用命名路由消除重复?
我不明白有什么区别
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
Run Code Online (Sandbox Code Playgroud)
从
Navigator.pushNamed(context, '/second');
Run Code Online (Sandbox Code Playgroud)
在重复的情况下。
使用具有多个导航图和 BottomNavigationView 的导航组件(类似于谷歌导航示例)我遇到了这样的问题。
我无法通过传递参数以编程方式从底部导航中的一个选项卡导航到另一个选项卡。例如,我在底部导航中有三个导航图和三个选项卡(每个选项卡一个图)。
我需要以编程方式从一个选项卡导航到另一个选项卡,以便“另一个”选项卡获得从第一个选项卡传递的参数。
谁能解释/评论这部分 Groovy 代码?
\n\ntask copyImageFolders(type: Copy) {\n from(\'images\') {\n include \'*.jpg\'\n into \'jpeg\'\n }\n\n from(\'images\') {\n include \'*.gif\'\n into \'gif\'\n }\n\n into \'build\'\n}\nRun Code Online (Sandbox Code Playgroud)\n\n更具体地了解from 方法。\n这是
\n\nfrom(sourcePaths)\nRun Code Online (Sandbox Code Playgroud)\n\n或者
\n\nfrom(sourcePath, configureAction)\nRun Code Online (Sandbox Code Playgroud)\n\n如果它有 2 个参数,为什么它\xe2\x80\x99 是这样写的,而不是这样的:
\n\n from(\'images\', {\n include \'*.jpg\'\n into \'jpeg\'\n })\nRun Code Online (Sandbox Code Playgroud)\n 我必须简单的路线,FirstRoute并且SecondRoute。每个都包含一个用于导航的按钮。按FirstRoute\ 的按钮会导致第二个,反之亦然。
当我第二次尝试从 导航FirstRoute到时,出现异常(第一次尝试成功)。从消息来看“处置后无法安装MaterialPageRouteSecondRoute ”来看,我以某种方式处置了一条路线,但我无法弄清楚哪条路线以及我是如何做到的。
这是完整的错误日志:
\n\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1 EXCEPTION CAUGHT BY GESTURE \xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nI/flutter (26569): The following assertion was thrown while handling a gesture:\nI/flutter (26569): Cannot install a MaterialPageRoute<void> after disposing it.\nI/flutter (26569): \'package:flutter/src/widgets/routes.dart\': Failed assertion: line 175 pos 12:\nI/flutter (26569): \'!_transitionCompleter.isCompleted\'\nI/flutter (26569): Either the assertion indicates an error in the framework itself, or we should provide substantially\nI/flutter (26569): more information in this …Run Code Online (Sandbox Code Playgroud) 该setUp()Junit的不叫,所以一NullPointerException当测试方法试图ACCES的抛出BankAccount对象。
我setUp()怎么了?
这是测试代码:
package my_package;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class BankAccountTest {
private BankAccount acc;
@Before
public void setUp(){
acc = new BankAccount(100);
}
@Test
void testDeposit() {
acc.deposit(50);
assertEquals(acc.getBalance(), 50);
}
@Test
void testWithdraw() {
acc.withdraw(50);
assertEquals(acc.getBalance(), 25);
}
@Test
void testWithdrawLimit() {
assertFalse(acc.withdraw(10000));
assertEquals(100, acc.getBalance());
assertTrue(acc.withdraw(1));
assertEquals(acc.getBalance(),99);
}
}
Run Code Online (Sandbox Code Playgroud)
这是应用程序代码:
package my_package;
public class BankAccount {
private int balance;
public BankAccount(int …Run Code Online (Sandbox Code Playgroud) 我的任务是在 Linux 上使用mono/.NET 4.7.2创建一个应用程序。
我有一些使用 .NET Core 的经验,但之前从未使用过 mono。所以我在运行 Ubuntu 20.04 的机器上安装了 mono,但我找不到它将使用的 dotnet 版本(因为我必须使用 4.7.2)。
mono --version没有来自或 的信息csc。
我有一些自定义 C# 对象,我想将它们作为InlineData参数传递到 xUnit 的Theory.
我尝试了这个问题的答案,但没有成功,因为我的对象不是字符串,因此不能创建为编译时常量(属性参数必须是属性参数类型的常量表达式、typeof 表达式或数组创建表达式)。
这是我尝试过的,
private static readonly Card sevenOfHearts = Card.SevenOfHearts;
private static readonly Card sevenOfSpades = Card.SevenOfSpades;
private static readonly Card sevenOfDiamonds = Card.SevenOfDiamonds;
private static readonly Card sevenOfClubs = Card.SevenOfClubs;
[Theory]
[InlineData(sevenOfHearts)]
[InlineData(sevenOfSpades)]
[InlineData(sevenOfDiamonds)]
[InlineData(sevenOfClubs)]
void Test(
Card card)
{
//...
}
Run Code Online (Sandbox Code Playgroud)
但我收到抱怨说这些对象不是编译时常量。
有什么替代方案吗?
android ×3
.net ×2
flutter ×2
java ×2
android-architecture-navigation ×1
android-wifi ×1
c# ×1
dart ×1
gradle ×1
groovy ×1
installation ×1
java-11 ×1
junit ×1
junit5 ×1
linux ×1
maui ×1
mono ×1
unit-testing ×1
wifi ×1
wifi-direct ×1
wifip2p ×1
xunit ×1