小编Aar*_*son的帖子

模块不安全的SAFESEH图像C++

我正在使用Microsoft Visual Studio 2011 Professional Beta

我正在尝试运行我使用cMake和Visual Studio Complier编译的OpenCV C++文件(http://opencv.willowgarage.com/wiki/Welcome).

然而,当我去调试项目时,我得到600多个错误,其中大多数是:

错误LNK2026:SAFESEH映像的模块不安全.

显然这些文件在opencv_ffmpeg项目中,但我找不到它们,我已经看过Microsoft帮助页面上的safeseh安全异常处理程序页面,但我找不到任何确定的答案.

我想知道是否有其他人有这个问题,如果他们设法解决它.

c++ visual-studio visual-c++

85
推荐指数
4
解决办法
9万
查看次数

ExecutorService与Casual Thread Spawner

我有一个关于如何ExecutorService在Java中工作的基本问题.

很难看出简单地创建Threads并行执行某些任务和将每个任务分配给它们之间的区别ThreadPool.

使用起来ExecutorService也非常简单和有效,所以我想知道为什么我们不一直使用它.

这只是一种比另一种方式更快地执行其工作的问题吗?

这里有两个非常简单的例子来说明两种方式之间的区别:

使用执行程序服务:Hello World(任务)

static class HelloTask implements Runnable {
    String msg;

    public HelloTask(String msg) {
        this.msg = msg; 
    }
    public void run() {
        long id = Thread.currentThread().getId();
        System.out.println(msg + " from thread:" + id);
    }
}
Run Code Online (Sandbox Code Playgroud)

使用执行程序服务:Hello World(创建执行程序,提交)

static class HelloTask {
    public static void main(String[] args) {
        int ntasks = 1000;
        ExecutorService exs = Executors.newFixedThreadPool(4);

        for (int i=0; i<ntasks; i++) { 
            HelloTask t = new HelloTask("Hello from …
Run Code Online (Sandbox Code Playgroud)

java multithreading executorservice

22
推荐指数
2
解决办法
1万
查看次数

活动构建变体没有测试工件

我基于“调试”构建变体创建了一个名为“bitrise”的新构建类型。使用“调试”构建变体时,已检测的 androidTests 构建并运行良好,但是当我切换到新的“bitrise”构建变体时,出现以下错误:

Process finished with exit code 1
Class not found: "com.mycompany.app.ui.race.RaceFragmentUiTest"
Run Code Online (Sandbox Code Playgroud)

当我选择“编辑配置...”->“Android Instrumented Tests”时出现此警告 警告:活动构建变体“myCompanyBitrise”没有测试工件。

版本

'com.android.tools.build:gradle:3.5.2'

安卓工作室 3.5.2

这是我的 Gradle 文件的摘录

buildTypes {
    debug {
        debuggable true
        testCoverageEnabled = false
        applicationIdSuffix ".debug"
        buildConfigField("String", "BASE_ENDPOINT", BASE_ENDPOINT_DEBUG)
    }
    release {
        minifyEnabled true
        zipAlignEnabled true
        shrinkResources true
        buildConfigField("String", "BASE_ENDPOINT", BASE_ENDPOINT_PROD)
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    bitrise {
        initWith debug
        buildConfigField("String", "BASE_ENDPOINT", BASE_ENDPOINT_PROD)
    }
}

flavorDimensions "version"

productFlavors {
    mycompany {
        dimension "version"
        applicationId "com.mycompany.app"
    }
    second {
        dimension "version"
        applicationId …
Run Code Online (Sandbox Code Playgroud)

android gradle android-testing android-gradle-plugin android-gradle-3.0

12
推荐指数
1
解决办法
3119
查看次数

Xamarin Android 7+以编程方式安装APK

我正在尝试安装已下载到Android 7中的downloads文件夹的.apk。

我已经尝试了一些StackOverflow帖子和此处https://inthecheesefactory.com/blog/how-to-share-access-to-file-with-fileprovider-on-android-nougat/en中推荐的方法,方法是使用FileProvider:

File file = new File(fileUri);
//using Android.Support.V4.Content;
var downloadUri = FileProvider.GetUriForFile(context,context.ApplicationContext.PackageName + ".com.package.name.provider", file);
Intent install = new Intent(Intent.ActionInstallPackage);
install.AddFlags(ActivityFlags.GrantReadUriPermission);
install.AddFlags(ActivityFlags.GrantWriteUriPermission);
install.AddFlags(ActivityFlags.GrantPersistableUriPermission);
install.SetDataAndType(downloadUri, "application/vnd.android.package-archive");
context.StartActivity(install);
Run Code Online (Sandbox Code Playgroud)

AndroidManifest.xml

<uses-permission android:name="android.permission.INSTALL_PACKAGES" />
<application android:label="Settings" android:icon="@drawable/Icon" android:theme="@style/myTheme">
    <provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}.com.package.name.provider"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/provider_paths"/>
    </provider>
</application>
Run Code Online (Sandbox Code Playgroud)

provider_paths.xml

<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="external_files" path="." /> 
</paths>
Run Code Online (Sandbox Code Playgroud)

“ downloadUri”看起来像:“ content://com.package.name.com.package.name.provider/external_files/Download/Sensors%2520Multitool_1.3.0_apk-dl​​.com.apk

弹出安装窗口时,错误为:“解析软件包时出现问题”

我通过在下载文件夹中单击安装此软件包,它安装正常,我也尝试了其他具有相同问题的.apk。

android xamarin.android xamarin

6
推荐指数
2
解决办法
1908
查看次数

从priv-app应用程序运行shell命令

我试图从我添加到AOSP(7.1.1)的system/priv-app运行shell命令

我试图运行的命令是:ip link add dev can0 type可以打开can总线.

我已经建立了图像既是-eng&-userdebug版本.该命令在adb shell中运行良好,并按预期成功打开CAN总线.

我的问题是我收到以下错误:

无法运行程序"su":错误= 13,权限被拒绝

当我在系统特权java应用程序中尝试以下代码时:

//ArrayList<String> commands is passed into the method
try {
  if (null != commands && commands.size() > 0) {
     Process suProcess = Runtime.getRuntime().exec("su");
     DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
     for (String currCommand : commands) {
        os.writeBytes(currCommand + "\n");
        os.flush();
     }
     os.writeBytes("exit\n");
     os.flush();
     BufferedReader stderr = new BufferedReader(new InputStreamReader(suProcess.getErrorStream()));
     String line = "";
     String errString = "";
     while ((line = stderr.readLine()) != null) errString …
Run Code Online (Sandbox Code Playgroud)

shell android android-source

6
推荐指数
1
解决办法
695
查看次数

adb root 工作 Runtime.GetRuntime().Exec("su"); 才不是

我在自定义设备上运行 android 7.1.1,并使用从“userdebug”配置中的源代码编译的 AOSP,该配置提供 root 访问和调试。

我可以使用 Android 设备桥连接到设备。

adb root
adb shell
device_name:/ # su
Run Code Online (Sandbox Code Playgroud)

所有这些命令都工作正常,我可以作为超级用户进行更改。我遇到的问题是从应用程序运行相同的“su”命令

Java.Lang.Process suProcess = Runtime.GetRuntime().Exec("su");
Run Code Online (Sandbox Code Playgroud)

我收到的错误是:

Java.IO.IOException:无法运行程序“su”:错误= 13,权限被拒绝

adb root/shell su 命令和从应用程序内运行的命令之间有区别吗?

android android-source xamarin.android

5
推荐指数
1
解决办法
9324
查看次数

Robolectric 测试永远不会结束

我正在使用 Robolectric 3.8 启动一个有意图的活动,然后测试布局是否设置正确。

这是我的测试代码:

Activity activity = Robolectric.buildActivity(MyModuleActivity.class, intent).create().visible().get();
Switch inputSwitch = (Switch)activity.findViewById(R.id.input_status_switch);
assertFalse("Switch should be off to start", inputSwitch.isChecked());
Run Code Online (Sandbox Code Playgroud)

我正在使用 .visible() 调用,如Robolectric:驱动活动生命周期中所述,否则 activity.findViewById 返回 null。

我在我的项目中测试了其他类似的活动,它们工作正常。我确定 setContentView() 在 onCreate 方法中被调用。

我的其他测试(没有 .visible())工作正常:

Activity inputActivity = Robolectric.buildActivity(InputModuleActivity.class).create().get();
assertThat(ShadowToast.getTextOfLatestToast(), equalTo("Unable to load config"));
Run Code Online (Sandbox Code Playgroud)

android robolectric

5
推荐指数
0
解决办法
173
查看次数

使用 IEqualityComparer 比较两个列表

我正在尝试比较两个包含复杂对象的 c# 列表。我知道以前有人问过类似的问题,但这略有不同。我正在关注 MSDN 示例:https : //msdn.microsoft.com/en-us/library/bb300779(v=vs.110).aspx

public class ProductA
{ 
    public string Name { get; set; }
    public int Code { get; set; }
}

public class ProductComparer : IEqualityComparer<ProductA>
{

    public bool Equals(ProductA x, ProductA y)
    {
        //Check whether the objects are the same object. 
        if (Object.ReferenceEquals(x, y)) return true;

        //Check whether the products' properties are equal. 
        return x != null && y != null && x.Code.Equals(y.Code) && x.Name.Equals(y.Name);
    }

    public int GetHashCode(ProductA obj)
    {
        //Get hash …
Run Code Online (Sandbox Code Playgroud)

c#

4
推荐指数
1
解决办法
4414
查看次数