我正在使用Intellij Java 2016.2.2和Maven来创建一个非常简单的Java控制台应用程序.
我想添加一个外部库,所以我在Maven中添加我的依赖项,如下所示:
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>2.12</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
它在IDE中运行时工作正常,但在外部控制台中没有(我有以下错误:java.lang.NoClassDefFoundError).
我检查过,由于某种原因,我刚刚生成的JAR中没有添加外部JAR.我还在"文件 - >项目结构"中尝试了很多东西,但仍然没有工作......
我只想用我的依赖项构建我的JAR,所以我可以使用以下命令在控制台中运行我的应用程序:
java -jar myproject.jar
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?谢谢你的帮助!
在我的Android项目中,我使用OpenSL ES来播放音频文件.我希望能够通过提取音频样本,处理它们并将它们重定向到音频输出来动态处理音频.
这是我到目前为止尝试的内容:
// create the engine and output mix objects
void Java_com_ywl5320_openslaudio_MainActivity_createEngine(JNIEnv* env, jclass clazz, int newsamplerate, int newbuffersize)
{
SLresult result;
audioBuffer = calloc(buffersize, sizeof(int16_t));
buffersize = newbuffersize;
samplerate = newsamplerate;
// create engine
result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// realize the engine
result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
assert(SL_RESULT_SUCCESS == result);
(void)result;
// get the engine interface, which is needed in order to create other objects
result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
assert(SL_RESULT_SUCCESS …Run Code Online (Sandbox Code Playgroud) 在我的 Android 应用程序中,我希望我的用户能够更改他们的电子邮件地址(他们用来连接到他们的帐户),而无需通过电子邮件获取任何验证码。
到目前为止,我设法更改了电子邮件地址,感谢 lambda,设置email_verified为true自动。但不幸的是,仍然发送了一封带有验证码的电子邮件......
这是我在我的 Android 应用程序中所做的:
public void onClickChangeEmail(View view)
{
CognitoUserAttributes attributes = new CognitoUserAttributes();
attributes.getAttributes().put("email", "second@mail.com");
CognitoSettings
.getCognitoUserPool(MainActivity.this)
.getCurrentUser()
.updateAttributesInBackground(attributes, new UpdateAttributesHandler()
{
@Override
public void onSuccess(List<CognitoUserCodeDeliveryDetails> attributesVerificationList)
{
Log.i("tag", "Email updated!");
}
@Override
public void onFailure(Exception e)
{
e.printStackTrace();
}
});
}
Run Code Online (Sandbox Code Playgroud)
在我的 AWS 控制台中,我在 Cognito 中的Custom message上添加了一个触发器,这是我的 lambda 函数,每次用户更新他的电子邮件时都会触发它:
const AWS = require('aws-sdk')
AWS.config.update({region: 'eu-central-1'});
exports.handler = (event, context, callback) => {
if (event.triggerSource === 'CustomMessage_UpdateUserAttribute')
{
const …Run Code Online (Sandbox Code Playgroud) 在我的 Flutter 项目中有多个屏幕,我想创建一个带有 2 个按钮的屏幕:
Navigator.pop()带有一个过渡,当前屏幕向右消失Navigator.pop(),但这次屏幕消失到底部到目前为止,我发现的每个示例都允许我在弹出屏幕时仅设置一种可能的转换。
另外,我使用命名路线在我的应用程序中导航。
如何根据用户点击的按钮自定义弹出动画?
谢谢。
在我的 Flutter 项目中,我调用原生 Android 代码和原生 iOS 代码。
在我的原生 Android 代码中,我用来Log.i("tag", "my log")记录我想要的任何内容,并且它会出现在 Logcat 和 Flutter 控制台中。
现在,我想从我的本机 iOS 代码中执行相同的操作。我试过:
print("my log")
NSLog("my log")
Run Code Online (Sandbox Code Playgroud)
但无论是在 Xcode 控制台还是在 Flutter 控制台中,任何地方都没有出现任何内容,这在调试时真的很烦人......
另外,我在 iOS 模拟器上运行我的应用程序。
那么如何从原生iOS代码中看到日志呢?
谢谢。
在我的 Windows Flutter 项目中,我想运行一些.exe要嵌入到项目中的文件,而不是手动将它们复制/粘贴到正确的位置。
所以我尝试将.exe文件添加到我的assets文件夹中,如下所示:
assets
\exe
\images
Run Code Online (Sandbox Code Playgroud)
并将exe文件夹添加到我的pubspec.yaml文件中,如下所示:
assets
\exe
\images
Run Code Online (Sandbox Code Playgroud)
好消息是:当我构建项目时,exe 文件被复制到正确的位置。坏消息是:我不知道如何exe在 Dart 中获取文件夹的绝对路径。
那么,有没有办法获取exeWindows 项目文件夹的绝对路径,或者是否有另一种方法来嵌入我的.exe文件,以便我可以获取它们的路径并运行它们(使用Process.start())?
谢谢。
在我的 Android 项目中,我想以安全的方式存储 API 密钥。该密钥是从应用程序外部生成的,需要在构建应用程序之前以某种方式存储在应用程序中。
我已经看到了一些如何使用 KeyStore 的示例(例如this或this),但据我了解,这些是存储运行时生成的密钥的解决方案,而不是我将存储在代码中某处的密钥。
我还检查了此处解释的其他方法,但由于逆向工程,它们看起来可以很容易地检索 API 密钥。
我也不想将我的密钥存储在我的代码中,也是因为它可以通过逆向工程轻松检索。
其目的是能够在每次调用我制作的网络服务时发送该密钥,因此我确定(或几乎确定)该调用来自我正在制作的原始应用程序,这将是在 Play 商店上发布,而不是从其他地方发布。
我远不是安全专家,所以任何帮助将不胜感激。
谢谢。
在我的 Windows Flutter 项目中,我使用该compute函数在 中运行一些代码Isolate,以避免冻结用户界面。
但我面临一个问题:我在其中运行的代码Isolate返回一个非常长的列表double(几百万个项目),因此,与我不这样做相比,整个执行花费了非常多的时间。Isolate根本不用。
这是进行多次计算并返回一个大列表的函数:
static Future<List<double>> extractWavSamples(File fileWav) async
{
// read the audio file:
Uint8List bytes = await fileWAV.readAsBytes();
bytes = bytes.sublist(44);
// convert to a list of doubles:
List<double> samples = [];
Uint8List samplesBytes = Uint8List(2);
int sample = 0;
for (int a = 0 ; a < bytes.length - 2 ; a += 2)
{
samplesBytes[0] = bytes.sublist(a + 1, a + 2)[0];
samplesBytes[1] …Run Code Online (Sandbox Code Playgroud) 在我的 Flutter 应用程序中,我使用go_router在页面之间导航。
以下是我的应用程序中的当前页面:
accounts_pageadd_account_pageimport_accounts_page现在,我想在 内部实现嵌套导航add_account_page,因此我可以使用多个步骤添加新帐户,比方说:
account_info_stepaccount_type_stepaccount_detail_step这是我尝试过的:
final _navigatorKey = GlobalKey<NavigatorState>();
final _addAccountNavigatorKey = GlobalKey<NavigatorState>();
late final router = GoRouter(
navigatorKey: _navigatorKey,
initialLocation: "/accounts_page",
routes: [
ShellRoute(
navigatorKey: _addAccountNavigatorKey,
builder: (context, state, child) => AddAccountPage(child: child),
routes: [
GoRoute(
parentNavigatorKey: _addAccountNavigatorKey,
name: "account_info_step",
path: "/account_info_step",
builder: (context, state) => const AccountInfoStep(),
),
GoRoute(
parentNavigatorKey: _addAccountNavigatorKey,
name: "account_type_step",
path: "/account_type_step",
builder: (context, state) => const AccountTypeStep(),
),
GoRoute(
parentNavigatorKey: _addAccountNavigatorKey,
name: …Run Code Online (Sandbox Code Playgroud) 在我的Android应用程序中使用FFMpeg库,我尝试了解如何在一个非常精确的位置搜索音频文件.
例如,我想将文件中的当前位置设置为帧#1234567(在44100 Hz编码的文件中),相当于27994.717毫秒的搜索.
为此,我尝试了以下内容:
// this:
av_seek_frame(formatContext, -1, 27994717, 0);
// or this:
av_seek_frame(formatContext, -1, 27994717, AVSEEK_FLAG_ANY);
// or even this:
avformat_seek_file(formatContext, -1, 27994617, 27994717, 27994817, 0);
Run Code Online (Sandbox Code Playgroud)
使用微秒的位置给我带来了迄今为止最好的结果.
但由于某种原因,定位并不完全准确:当我从音频文件中提取样本时,它并不完全在预期位置开始.有一点点延迟大约30-40毫秒(即使我寻找位置0,令人惊讶......).
我是否以正确的方式使用该功能,甚至是正确的功能?
编辑
以下是我如何获得这个职位:
AVPacket packet;
AVStream *stream = NULL;
AVFormatContext *formatContext = NULL;
AVCodec *dec = NULL;
// initialization:
avformat_open_input(&formatContext, filename, NULL, NULL);
avformat_find_stream_info(formatContext, NULL);
int audio_stream_index = av_find_best_stream(formatContext, AVMEDIA_TYPE_AUDIO, -1, -1, &dec, 0);
stream = formatContext->streams[audio_stream_index];
...
// later, when I extract samples, here is how I get my position, …Run Code Online (Sandbox Code Playgroud)